Skip to content

Commit

Permalink
docs: Fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Aug 19, 2024
1 parent 43b1808 commit a212f80
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 7 additions & 3 deletions src/helpers/GenerateDocs/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a212f80

Please sign in to comment.