From a212f80ba5289ccf314a68f5d7bb83aa2ae09f18 Mon Sep 17 00:00:00 2001 From: HavenDV Date: Mon, 19 Aug 2024 18:46:03 +0400 Subject: [PATCH] docs: Fixed. --- .github/workflows/mkdocs.yml | 2 ++ src/helpers/GenerateDocs/Program.cs | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/mkdocs.yml b/.github/workflows/mkdocs.yml index 5c80b989..44b610ba 100644 --- a/.github/workflows/mkdocs.yml +++ b/.github/workflows/mkdocs.yml @@ -7,6 +7,8 @@ on: - 'docs/**' - 'mkdocs.yml' - 'examples/**' + - 'src/helpers/GenerateDocs/**' + - '.github/workflows/mkdocs.yml' # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages permissions: diff --git a/src/helpers/GenerateDocs/Program.cs b/src/helpers/GenerateDocs/Program.cs index 4ef4ff7b..b78f5f77 100644 --- a/src/helpers/GenerateDocs/Program.cs +++ b/src/helpers/GenerateDocs/Program.cs @@ -2,14 +2,18 @@ var sampleDirectory = Path.Combine(solutionDirectory, "src", "tests", "OpenAI.IntegrationTests", "Examples"); var mkDocsPath = Path.Combine(solutionDirectory, "mkdocs.yml"); +var newDir = Path.Combine(solutionDirectory, "docs", "samples"); +Directory.CreateDirectory(newDir); + +File.Copy( + Path.Combine(solutionDirectory, "README.md"), + Path.Combine(solutionDirectory, "docs", "index.md")); + Console.WriteLine($"Generating samples from {sampleDirectory}..."); foreach (var path in Directory.EnumerateFiles(sampleDirectory, "*.cs", SearchOption.AllDirectories)) { var code = await File.ReadAllTextAsync(path); - var newDir = Path.Combine(solutionDirectory, "docs", "samples"); - Directory.CreateDirectory(newDir); - var start = code.IndexOf("\n {", StringComparison.Ordinal); var end = code.IndexOf("\n }", StringComparison.Ordinal); code = code.Substring(start + 4, end - start + 4);