Skip to content

Commit 74b6c34

Browse files
committed
better defaults for watch command
1 parent 55969a5 commit 74b6c34

File tree

4 files changed

+108
-87
lines changed

4 files changed

+108
-87
lines changed

src/docfx/Models/BuildCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public override int Execute(CommandContext context, BuildCommandOptions settings
2929
});
3030
}
3131

32-
internal static void MergeOptionsToConfig(BuildCommandOptions options, BuildJsonConfig config, string configDirectory)
32+
internal static void MergeOptionsToConfig(DefaultBuildCommandOptions options, BuildJsonConfig config, string configDirectory)
3333
{
3434
// base directory for content from command line is current directory
3535
// e.g. C:\folder1>docfx build folder2\docfx.json --content "*.cs"

src/docfx/Models/BuildCommandOptions.cs

Lines changed: 1 addition & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -7,97 +7,13 @@
77
namespace Docfx;
88

99
[Description("Generate client-only website combining API in YAML files and conceptual files")]
10-
internal class BuildCommandOptions : LogOptions
10+
internal class BuildCommandOptions : DefaultBuildCommandOptions
1111
{
12-
[Description("Specify the output base directory")]
13-
[CommandOption("-o|--output")]
14-
public string OutputFolder { get; set; }
15-
16-
[Description("Path to docfx.json")]
17-
[CommandArgument(0, "[config]")]
18-
public string ConfigFile { get; set; }
19-
20-
[Description("Specify a list of global metadata in key value pairs (e.g. --metadata _appTitle=\"My App\" --metadata _disableContribution)")]
21-
[CommandOption("-m|--metadata")]
22-
public string[] Metadata { get; set; }
23-
24-
[Description("Specify the urls of xrefmap used by content files.")]
25-
[CommandOption("-x|--xref")]
26-
[TypeConverter(typeof(ArrayOptionConverter))]
27-
public IEnumerable<string> XRefMaps { get; set; }
28-
29-
[Description("Specify the template name to apply to. If not specified, output YAML file will not be transformed.")]
30-
[CommandOption("-t|--template")]
31-
[TypeConverter(typeof(ArrayOptionConverter))]
32-
public IEnumerable<string> Templates { get; set; }
33-
34-
[Description("Specify which theme to use. By default 'default' theme is offered.")]
35-
[CommandOption("--theme")]
36-
[TypeConverter(typeof(ArrayOptionConverter))]
37-
public IEnumerable<string> Themes { get; set; }
38-
3912
[Description("Host the generated documentation to a website")]
4013
[CommandOption("-s|--serve")]
4114
public bool Serve { get; set; }
4215

43-
[Description("Specify the hostname of the hosted website (e.g., 'localhost' or '*')")]
44-
[CommandOption("-n|--hostname")]
45-
public string Host { get; set; }
46-
47-
[Description("Specify the port of the hosted website")]
48-
[CommandOption("-p|--port")]
49-
public int? Port { get; set; }
50-
5116
[Description("Open a web browser when the hosted website starts.")]
5217
[CommandOption("--open-browser")]
5318
public bool OpenBrowser { get; set; }
54-
55-
[Description("Open a file in a web browser when the hosted website starts.")]
56-
[CommandOption("--open-file <RELATIVE_PATH>")]
57-
public string OpenFile { get; set; }
58-
59-
[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.")]
60-
[CommandOption("--debug")]
61-
public bool EnableDebugMode { get; set; }
62-
63-
[Description("The output folder for files generated for debugging purpose when in debug mode. If not specified, it is ${TempPath}/docfx")]
64-
[CommandOption("--debugOutput")]
65-
public string OutputFolderForDebugFiles { get; set; }
66-
67-
[Description("If set to true, data model to run template script will be extracted in .raw.model.json extension")]
68-
[CommandOption("--exportRawModel")]
69-
public bool ExportRawModel { get; set; }
70-
71-
[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")]
72-
[CommandOption("--rawModelOutputFolder")]
73-
public string RawModelOutputFolder { get; set; }
74-
75-
[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")]
76-
[CommandOption("--viewModelOutputFolder")]
77-
public string ViewModelOutputFolder { get; set; }
78-
79-
[Description("If set to true, data model to apply template will be extracted in .view.model.json extension")]
80-
[CommandOption("--exportViewModel")]
81-
public bool ExportViewModel { get; set; }
82-
83-
[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.")]
84-
[CommandOption("--dryRun")]
85-
public bool DryRun { get; set; }
86-
87-
[Description("Set the max parallelism, 0 is auto.")]
88-
[CommandOption("--maxParallelism")]
89-
public int? MaxParallelism { get; set; }
90-
91-
[Description("Set the parameters for markdown engine, value should be a JSON string.")]
92-
[CommandOption("--markdownEngineProperties")]
93-
public string MarkdownEngineProperties { get; set; }
94-
95-
[Description("Set the order of post processors in plugins")]
96-
[CommandOption("--postProcessors")]
97-
[TypeConverter(typeof(ArrayOptionConverter))]
98-
public IEnumerable<string> PostProcessors { get; set; }
99-
100-
[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.")]
101-
[CommandOption("--disableGitFeatures")]
102-
public bool DisableGitFeatures { get; set; }
10319
}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System.ComponentModel;
5+
using Spectre.Console.Cli;
6+
7+
namespace Docfx;
8+
9+
internal class DefaultBuildCommandOptions : LogOptions
10+
{
11+
[Description("Specify the output base directory")]
12+
[CommandOption("-o|--output")]
13+
public string OutputFolder { get; set; }
14+
15+
[Description("Path to docfx.json")]
16+
[CommandArgument(0, "[config]")]
17+
public string ConfigFile { get; set; }
18+
19+
[Description("Specify a list of global metadata in key value pairs (e.g. --metadata _appTitle=\"My App\" --metadata _disableContribution)")]
20+
[CommandOption("-m|--metadata")]
21+
public string[] Metadata { get; set; }
22+
23+
[Description("Specify the urls of xrefmap used by content files.")]
24+
[CommandOption("-x|--xref")]
25+
[TypeConverter(typeof(ArrayOptionConverter))]
26+
public IEnumerable<string> XRefMaps { get; set; }
27+
28+
[Description("Specify the template name to apply to. If not specified, output YAML file will not be transformed.")]
29+
[CommandOption("-t|--template")]
30+
[TypeConverter(typeof(ArrayOptionConverter))]
31+
public IEnumerable<string> Templates { get; set; }
32+
33+
[Description("Specify which theme to use. By default 'default' theme is offered.")]
34+
[CommandOption("--theme")]
35+
[TypeConverter(typeof(ArrayOptionConverter))]
36+
public IEnumerable<string> Themes { get; set; }
37+
38+
[Description("Specify the hostname of the hosted website (e.g., 'localhost' or '*')")]
39+
[CommandOption("-n|--hostname")]
40+
public string Host { get; set; }
41+
42+
[Description("Specify the port of the hosted website")]
43+
[CommandOption("-p|--port")]
44+
public int? Port { get; set; }
45+
46+
[Description("Open a file in a web browser when the hosted website starts.")]
47+
[CommandOption("--open-file <RELATIVE_PATH>")]
48+
public string OpenFile { get; set; }
49+
50+
[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.")]
51+
[CommandOption("--debug")]
52+
public bool EnableDebugMode { get; set; }
53+
54+
[Description("The output folder for files generated for debugging purpose when in debug mode. If not specified, it is ${TempPath}/docfx")]
55+
[CommandOption("--debugOutput")]
56+
public string OutputFolderForDebugFiles { get; set; }
57+
58+
[Description("If set to true, data model to run template script will be extracted in .raw.model.json extension")]
59+
[CommandOption("--exportRawModel")]
60+
public bool ExportRawModel { get; set; }
61+
62+
[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")]
63+
[CommandOption("--rawModelOutputFolder")]
64+
public string RawModelOutputFolder { get; set; }
65+
66+
[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")]
67+
[CommandOption("--viewModelOutputFolder")]
68+
public string ViewModelOutputFolder { get; set; }
69+
70+
[Description("If set to true, data model to apply template will be extracted in .view.model.json extension")]
71+
[CommandOption("--exportViewModel")]
72+
public bool ExportViewModel { get; set; }
73+
74+
[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.")]
75+
[CommandOption("--dryRun")]
76+
public bool DryRun { get; set; }
77+
78+
[Description("Set the max parallelism, 0 is auto.")]
79+
[CommandOption("--maxParallelism")]
80+
public int? MaxParallelism { get; set; }
81+
82+
[Description("Set the parameters for markdown engine, value should be a JSON string.")]
83+
[CommandOption("--markdownEngineProperties")]
84+
public string MarkdownEngineProperties { get; set; }
85+
86+
[Description("Set the order of post processors in plugins")]
87+
[CommandOption("--postProcessors")]
88+
[TypeConverter(typeof(ArrayOptionConverter))]
89+
public IEnumerable<string> PostProcessors { get; set; }
90+
91+
[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.")]
92+
[CommandOption("--disableGitFeatures")]
93+
public bool DisableGitFeatures { get; set; }
94+
}

src/docfx/Models/WatchCommandOptions.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,20 @@
77
namespace Docfx;
88

99
[Description("Generate client-only website combining API in YAML files and conceptual files and watch them for changes")]
10-
internal class WatchCommandOptions : BuildCommandOptions
10+
internal class WatchCommandOptions : DefaultBuildCommandOptions
1111
{
1212
[Description("Should directory be watched and website re-rendered on changes.")]
1313
[CommandOption("-w|--watch")]
14+
[DefaultValue("true")]
1415
public bool Watch { get; set; }
16+
17+
[Description("Host the generated documentation to a website")]
18+
[CommandOption("-s|--serve")]
19+
[DefaultValue("true")]
20+
public bool Serve { get; set; }
21+
22+
[Description("Open a web browser when the hosted website starts.")]
23+
[CommandOption("--open-browser")]
24+
[DefaultValue("false")]
25+
public bool OpenBrowser { get; set; }
1526
}

0 commit comments

Comments
 (0)