Skip to content

Commit

Permalink
better defaults for watch command
Browse files Browse the repository at this point in the history
  • Loading branch information
rmannibucau committed Jun 22, 2024
1 parent b6910f7 commit cb175c8
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 87 deletions.
2 changes: 1 addition & 1 deletion src/docfx/Models/BuildCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public override int Execute(CommandContext context, BuildCommandOptions settings
});
}

internal static void MergeOptionsToConfig(BuildCommandOptions options, BuildJsonConfig config, string configDirectory)
internal static void MergeOptionsToConfig(DefaultBuildCommandOptions options, BuildJsonConfig config, string configDirectory)
{
// base directory for content from command line is current directory
// e.g. C:\folder1>docfx build folder2\docfx.json --content "*.cs"
Expand Down
86 changes: 1 addition & 85 deletions src/docfx/Models/BuildCommandOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,97 +7,13 @@
namespace Docfx;

[Description("Generate client-only website combining API in YAML files and conceptual files")]
internal class BuildCommandOptions : LogOptions
internal class BuildCommandOptions : DefaultBuildCommandOptions
{
[Description("Specify the output base directory")]
[CommandOption("-o|--output")]
public string OutputFolder { get; set; }

[Description("Path to docfx.json")]
[CommandArgument(0, "[config]")]
public string ConfigFile { get; set; }

[Description("Specify a list of global metadata in key value pairs (e.g. --metadata _appTitle=\"My App\" --metadata _disableContribution)")]
[CommandOption("-m|--metadata")]
public string[] Metadata { get; set; }

[Description("Specify the urls of xrefmap used by content files.")]
[CommandOption("-x|--xref")]
[TypeConverter(typeof(ArrayOptionConverter))]
public IEnumerable<string> XRefMaps { get; set; }

[Description("Specify the template name to apply to. If not specified, output YAML file will not be transformed.")]
[CommandOption("-t|--template")]
[TypeConverter(typeof(ArrayOptionConverter))]
public IEnumerable<string> Templates { get; set; }

[Description("Specify which theme to use. By default 'default' theme is offered.")]
[CommandOption("--theme")]
[TypeConverter(typeof(ArrayOptionConverter))]
public IEnumerable<string> Themes { get; set; }

[Description("Host the generated documentation to a website")]
[CommandOption("-s|--serve")]
public bool Serve { get; set; }

[Description("Specify the hostname of the hosted website (e.g., 'localhost' or '*')")]
[CommandOption("-n|--hostname")]
public string Host { get; set; }

[Description("Specify the port of the hosted website")]
[CommandOption("-p|--port")]
public int? Port { get; set; }

[Description("Open a web browser when the hosted website starts.")]
[CommandOption("--open-browser")]
public bool OpenBrowser { get; set; }

[Description("Open a file in a web browser when the hosted website starts.")]
[CommandOption("--open-file <RELATIVE_PATH>")]
public string OpenFile { get; set; }

[Description("Run in debug mode. With debug mode, raw model and view model will be exported automatically when it encounters error when applying templates. If not specified, it is false.")]
[CommandOption("--debug")]
public bool EnableDebugMode { get; set; }

[Description("The output folder for files generated for debugging purpose when in debug mode. If not specified, it is ${TempPath}/docfx")]
[CommandOption("--debugOutput")]
public string OutputFolderForDebugFiles { get; set; }

[Description("If set to true, data model to run template script will be extracted in .raw.model.json extension")]
[CommandOption("--exportRawModel")]
public bool ExportRawModel { get; set; }

[Description("Specify the output folder for the raw model. If not set, the raw model will be generated to the same folder as the output documentation")]
[CommandOption("--rawModelOutputFolder")]
public string RawModelOutputFolder { get; set; }

[Description("Specify the output folder for the view model. If not set, the view model will be generated to the same folder as the output documentation")]
[CommandOption("--viewModelOutputFolder")]
public string ViewModelOutputFolder { get; set; }

[Description("If set to true, data model to apply template will be extracted in .view.model.json extension")]
[CommandOption("--exportViewModel")]
public bool ExportViewModel { get; set; }

[Description("If set to true, template will not be actually applied to the documents. This option is always used with --exportRawModel or --exportViewModel is set so that only raw model files or view model files are generated.")]
[CommandOption("--dryRun")]
public bool DryRun { get; set; }

[Description("Set the max parallelism, 0 is auto.")]
[CommandOption("--maxParallelism")]
public int? MaxParallelism { get; set; }

[Description("Set the parameters for markdown engine, value should be a JSON string.")]
[CommandOption("--markdownEngineProperties")]
public string MarkdownEngineProperties { get; set; }

[Description("Set the order of post processors in plugins")]
[CommandOption("--postProcessors")]
[TypeConverter(typeof(ArrayOptionConverter))]
public IEnumerable<string> PostProcessors { get; set; }

[Description("Disable fetching Git related information for articles. By default it is enabled and may have side effect on performance when the repo is large.")]
[CommandOption("--disableGitFeatures")]
public bool DisableGitFeatures { get; set; }
}
94 changes: 94 additions & 0 deletions src/docfx/Models/DefaultBuildCommandOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.ComponentModel;
using Spectre.Console.Cli;

namespace Docfx;

internal class DefaultBuildCommandOptions : LogOptions
{
[Description("Specify the output base directory")]
[CommandOption("-o|--output")]
public string OutputFolder { get; set; }

[Description("Path to docfx.json")]
[CommandArgument(0, "[config]")]
public string ConfigFile { get; set; }

[Description("Specify a list of global metadata in key value pairs (e.g. --metadata _appTitle=\"My App\" --metadata _disableContribution)")]
[CommandOption("-m|--metadata")]
public string[] Metadata { get; set; }

[Description("Specify the urls of xrefmap used by content files.")]
[CommandOption("-x|--xref")]
[TypeConverter(typeof(ArrayOptionConverter))]
public IEnumerable<string> XRefMaps { get; set; }

[Description("Specify the template name to apply to. If not specified, output YAML file will not be transformed.")]
[CommandOption("-t|--template")]
[TypeConverter(typeof(ArrayOptionConverter))]
public IEnumerable<string> Templates { get; set; }

[Description("Specify which theme to use. By default 'default' theme is offered.")]
[CommandOption("--theme")]
[TypeConverter(typeof(ArrayOptionConverter))]
public IEnumerable<string> Themes { get; set; }

[Description("Specify the hostname of the hosted website (e.g., 'localhost' or '*')")]
[CommandOption("-n|--hostname")]
public string Host { get; set; }

[Description("Specify the port of the hosted website")]
[CommandOption("-p|--port")]
public int? Port { get; set; }

[Description("Open a file in a web browser when the hosted website starts.")]
[CommandOption("--open-file <RELATIVE_PATH>")]
public string OpenFile { get; set; }

[Description("Run in debug mode. With debug mode, raw model and view model will be exported automatically when it encounters error when applying templates. If not specified, it is false.")]
[CommandOption("--debug")]
public bool EnableDebugMode { get; set; }

[Description("The output folder for files generated for debugging purpose when in debug mode. If not specified, it is ${TempPath}/docfx")]
[CommandOption("--debugOutput")]
public string OutputFolderForDebugFiles { get; set; }

[Description("If set to true, data model to run template script will be extracted in .raw.model.json extension")]
[CommandOption("--exportRawModel")]
public bool ExportRawModel { get; set; }

[Description("Specify the output folder for the raw model. If not set, the raw model will be generated to the same folder as the output documentation")]
[CommandOption("--rawModelOutputFolder")]
public string RawModelOutputFolder { get; set; }

[Description("Specify the output folder for the view model. If not set, the view model will be generated to the same folder as the output documentation")]
[CommandOption("--viewModelOutputFolder")]
public string ViewModelOutputFolder { get; set; }

[Description("If set to true, data model to apply template will be extracted in .view.model.json extension")]
[CommandOption("--exportViewModel")]
public bool ExportViewModel { get; set; }

[Description("If set to true, template will not be actually applied to the documents. This option is always used with --exportRawModel or --exportViewModel is set so that only raw model files or view model files are generated.")]
[CommandOption("--dryRun")]
public bool DryRun { get; set; }

[Description("Set the max parallelism, 0 is auto.")]
[CommandOption("--maxParallelism")]
public int? MaxParallelism { get; set; }

[Description("Set the parameters for markdown engine, value should be a JSON string.")]
[CommandOption("--markdownEngineProperties")]
public string MarkdownEngineProperties { get; set; }

[Description("Set the order of post processors in plugins")]
[CommandOption("--postProcessors")]
[TypeConverter(typeof(ArrayOptionConverter))]
public IEnumerable<string> PostProcessors { get; set; }

[Description("Disable fetching Git related information for articles. By default it is enabled and may have side effect on performance when the repo is large.")]
[CommandOption("--disableGitFeatures")]
public bool DisableGitFeatures { get; set; }
}
13 changes: 12 additions & 1 deletion src/docfx/Models/WatchCommandOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,20 @@
namespace Docfx;

[Description("Generate client-only website combining API in YAML files and conceptual files and watch them for changes")]
internal class WatchCommandOptions : BuildCommandOptions
internal class WatchCommandOptions : DefaultBuildCommandOptions
{
[Description("Should directory be watched and website re-rendered on changes.")]
[CommandOption("-w|--watch")]
[DefaultValue("true")]
public bool Watch { get; set; }

[Description("Host the generated documentation to a website")]
[CommandOption("-s|--serve")]
[DefaultValue("true")]
public bool Serve { get; set; }

[Description("Open a web browser when the hosted website starts.")]
[CommandOption("--open-browser")]
[DefaultValue("false")]
public bool OpenBrowser { get; set; }
}

0 comments on commit cb175c8

Please sign in to comment.