Skip to content

Commit

Permalink
Merging snippet generation logic into OneDrive/apidoctor (#59)
Browse files Browse the repository at this point in the history
* Snippet generations running on pipelines

* Add before checking for changes

* Handling exception tests

* Updates to include sdk documentation links into docs

* Updates to include header to show auto-generated files in snippet generation.

* Reworks Snippet injection to around the http tab section

* Makes PR title and commit message parameters and enables tabs renaming

* Try it updates

* Fix locale and only dump new files

* Tiny fix

* Fix runs

* Update apidoctor to consume snippet generation command line tool instead of HTTP endpoint (#1)

* add skip-publishing-changes flag to skip creating pull request upon generation

* integrate snippet generator tool

* consider the version information

* apply fixes from generate-snippets branch

* remove Github helper

* clean up command line options

* remove unused git commands, make GitHelper closer to that of master's

* add summary tags

* fix static method call

* add custom metadata path

* Fix broken test

* Update ApiDoctor.Validation/Http/HttpParser.cs

Co-authored-by: Vincent Biret <[email protected]>

Co-authored-by: Andrew Omondi <[email protected]>
Co-authored-by: Andrew Omondi <[email protected]>
Co-authored-by: Andrew Omondi <ApiDoctor>
Co-authored-by: Eastman <[email protected]>
Co-authored-by: Andrew Omondi <[email protected]>
Co-authored-by: Vincent Biret <[email protected]>
  • Loading branch information
6 people authored Dec 10, 2020
1 parent cac6235 commit c8e2374
Show file tree
Hide file tree
Showing 6 changed files with 423 additions and 39 deletions.
4 changes: 3 additions & 1 deletion ApiDoctor.Console/ApiDoctor.ConsoleApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
Expand All @@ -25,7 +26,6 @@
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
Expand Down Expand Up @@ -78,6 +78,8 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
Expand Down
16 changes: 16 additions & 0 deletions ApiDoctor.Console/CommandLineOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class CommandLineOptions
public const string VerbPublishMetadata = "publish-edmx";

public const string VerbGenerateDocs = "generate-docs";
public const string VerbGenerateSnippets = "generate-snippets";

[VerbOption(VerbPrint, HelpText = "Print files, resources, and methods discovered in the documentation.")]
public PrintOptions PrintVerbOptions { get; set; }
Expand Down Expand Up @@ -81,6 +82,9 @@ class CommandLineOptions
[VerbOption(VerbGenerateDocs, HelpText = "Generate documentation from an CSDL model")]
public GenerateDocsOptions GenerateDocsVerb { get; set; }

[VerbOption(VerbGenerateSnippets, HelpText = "Generate code snippets from requests in documentation")]
public GenerateSnippetsOptions GenerateSnippetsVerb { get; set; }

[VerbOption(VerbAbout, HelpText = "Print about information for this application.")]
public BaseOptions AboutVerb { get; set; }

Expand Down Expand Up @@ -620,4 +624,16 @@ class GenerateDocsOptions : CheckMetadataOptions
[Option("resource-template", HelpText = "Specifies the path to a mustache template file to use for generating documentation for resources (complex and entity types)", Required = false)]
public string ResourceTemplateFile { get; set; }
}

class GenerateSnippetsOptions : BasicCheckOptions
{
[Option("snippet-generator-path", HelpText = "Full Path to the snippet generator url", Required = true)]
public string SnippetGeneratorPath { get; set; }

[Option("lang", HelpText = "The programming languages for snippet generation(comma separated list)", Required = true)]
public string Languages { get; set; }

[Option("custom-metadata-path", HelpText = "Path to custom metadata that snippet generation can consume", Required = false)]
public string CustomMetadataPath { get; set; }
}
}
24 changes: 14 additions & 10 deletions ApiDoctor.Console/GitHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* API Doctor
* Copyright (c) Microsoft Corporation
* All rights reserved.
Expand Down Expand Up @@ -96,16 +96,18 @@ public static string FindGitLocation()

private static string RunCommand(string executable, string arguments, string workingDirectory = null)
{
ProcessStartInfo parameters = new ProcessStartInfo();
parameters.CreateNoWindow = true;
parameters.UseShellExecute = false;
parameters.RedirectStandardError = true;
parameters.RedirectStandardOutput = true;
parameters.FileName = executable;
parameters.Arguments = arguments;
if (null != workingDirectory)
parameters.WorkingDirectory = workingDirectory;
ProcessStartInfo parameters = new ProcessStartInfo
{
CreateNoWindow = true,
UseShellExecute = false,
RedirectStandardError = true,
RedirectStandardOutput = true,
FileName = executable,
Arguments = arguments
};

if (null != workingDirectory)
parameters.WorkingDirectory = workingDirectory;

var p = Process.Start(parameters);

Expand All @@ -116,6 +118,8 @@ private static string RunCommand(string executable, string arguments, string wor
sb.AppendLine(currentLine);
}

p.WaitForExit();

return sb.ToString();

}
Expand Down
Loading

0 comments on commit c8e2374

Please sign in to comment.