@@ -47,112 +47,14 @@ int ddoxMain(string[] args)
4747 return 1 ;
4848}
4949
50- int cmdGenerateHtml (string [] args)
51- {
52- GeneratorSettings gensettings;
53- Package pack;
54- if ( auto ret = setupGeneratorInput(args, gensettings, pack) )
55- return ret;
56-
57- generateHtmlDocs(Path(args[3 ]), pack, gensettings);
58- return 0 ;
59- }
60-
61- int cmdServeHtml (string [] args)
62- {
63- string [] webfiledirs;
64- getopt(args,
65- config.passThrough,
66- " web-file-dir" , &webfiledirs);
67-
68- GeneratorSettings gensettings;
69- Package pack;
70- if ( auto ret = setupGeneratorInput(args, gensettings, pack) )
71- return ret;
72-
73- // register the api routes and start the server
74- auto router = new URLRouter;
75- registerApiDocs(router, pack, gensettings);
76-
77- foreach (dir; webfiledirs)
78- router.get (" *" , serveStaticFiles(dir));
79-
80- writefln(" Listening on port 8080..." );
81- auto settings = new HTTPServerSettings;
82- settings.port = 8080 ;
83- listenHTTP(settings, router);
84-
85- return runEventLoop ();
86- }
87-
88- int cmdServeTest (string [] args)
89- {
90- string [] webfiledirs;
91- auto docsettings = new DdoxSettings;
92- auto gensettings = new GeneratorSettings;
50+ static import ddox.main;
9351
94- auto pack = parseD(args[2 .. $]);
95-
96- processDocs(pack, docsettings);
97-
98- // register the api routes and start the server
99- auto router = new URLRouter;
100- registerApiDocs(router, pack, gensettings);
101-
102- foreach (dir; webfiledirs)
103- router.get (" *" , serveStaticFiles(dir));
104-
105- writefln(" Listening on port 8080..." );
106- auto settings = new HTTPServerSettings;
107- settings.port = 8080 ;
108- listenHTTP(settings, router);
109-
110- return runEventLoop ();
111- }
112-
113- int setupGeneratorInput (ref string [] args, out GeneratorSettings gensettings, out Package pack)
114- {
115- gensettings = new GeneratorSettings;
116- auto docsettings = new DdoxSettings;
117-
118- string [] macrofiles;
119- string [] overridemacrofiles;
120- string sitemapurl = " http://127.0.0.1/" ;
121- bool lowercasenames;
122- bool hyphenate;
123- getopt(args,
124- // config.passThrough,
125- " decl-sort" , &docsettings.declSort,
126- " file-name-style" , &gensettings.fileNameStyle,
127- " hyphenate" , &hyphenate,
128- " lowercase-names" , &lowercasenames,
129- " module-sort" , &docsettings.moduleSort,
130- " navigation-type" , &gensettings.navigationType,
131- " override-macros" , &overridemacrofiles,
132- " package-order" , &docsettings.packageOrder,
133- " sitemap-url" , &sitemapurl,
134- " std-macros" , ¯ofiles,
135- " enum-member-pages" , &gensettings.enumMemberPages,
136- " html-style" , &gensettings.htmlOutputStyle,
137- );
138- gensettings.siteUrl = URL (sitemapurl);
139-
140- if (lowercasenames) gensettings.fileNameStyle = MethodStyle.lowerCase;
141-
142- if ( args.length < 3 ){
143- showUsage(args);
144- return 1 ;
145- }
146-
147- setDefaultDdocMacroFiles(macrofiles);
148- setOverrideDdocMacroFiles(overridemacrofiles);
149- if (hyphenate) enableHyphenation();
150-
151- // parse the json output file
152- pack = parseDocFile(args[2 ], docsettings);
153-
154- return 0 ;
155- }
52+ alias cmdGenerateHtml = ddox.main.cmdGenerateHtml;
53+ alias cmdServeHtml = ddox.main.cmdServeTest;
54+ alias cmdServeTest = ddox.main.cmdServeTest;
55+ alias parseDocFile = ddox.main.parseDocFile;
56+ alias setupGeneratorInput = ddox.main.setupGeneratorInput;
57+ alias showUsage = ddox.main.showUsage;
15658
15759int cmdFilterDocs (string [] args)
15860{
@@ -298,122 +200,7 @@ int cmdFilterDocs(string[] args)
298200 return 0 ;
299201}
300202
301- Package parseDocFile (string filename, DdoxSettings settings)
302- {
303- writefln(" Reading doc file..." );
304- auto text = readText(filename);
305- int line = 1 ;
306- writefln(" Parsing JSON..." );
307- auto json = parseJson(text, &line);
308- writefln(" Parsing docs..." );
309- Package root;
310- root = parseJsonDocs(json);
311- writefln(" Finished parsing docs." );
312-
313- processDocs(root, settings);
314- return root;
315- }
316-
317- void showUsage (string [] args)
318- {
319- string cmd;
320- if ( args.length >= 2 ) cmd = args[1 ];
321-
322- switch (cmd){
323- default :
324- writefln(
325- ` Usage: %s <COMMAND> [args...]
326-
327- <COMMAND> can be one of:
328- generate-html
329- serve-html
330- filter
331-
332- -h --help Show this help
333-
334- Use <COMMAND> -h|--help to get detailed usage information for a command.
335- ` , args[0 ]);
336- break ;
337- case " serve-html" :
338- writefln(
339- ` Usage: %s serve-html <ddocx-input-file>
340- --std-macros=FILE File containing DDOC macros that will be available
341- --override-macros=FILE File containing DDOC macros that will override local
342- definitions (Macros: section)
343- --navigation-type=TYPE Change the type of navigation (ModuleList,
344- ModuleTree (default), DeclarationTree)
345- --package-order=NAME Causes the specified module to be ordered first. Can
346- be specified multiple times.
347- --sitemap-url Specifies the base URL used for sitemap generation
348- --module-sort=MODE The sort order used for lists of modules
349- --decl-sort=MODE The sort order used for declaration lists
350- --web-file-dir=DIR Make files from dir available on the served site
351- --enum-member-pages Generate a single page per enum member
352- --html-style=STYLE Sets the HTML output style, either pretty (default)
353- or compact.
354- --hyphenate hyphenate text
355- -h --help Show this help
356-
357- The following values can be used as sorting modes: none, name, protectionName,
358- protectionInheritanceName
359- ` , args[0 ]);
360- break ;
361- case " generate-html" :
362- writefln(
363- ` Usage: %s generate-html <ddocx-input-file> <output-dir>
364- --std-macros=FILE File containing DDOC macros that will be available
365- --override-macros=FILE File containing DDOC macros that will override local
366- definitions (Macros: section)
367- --navigation-type=TYPE Change the type of navigation (ModuleList,
368- ModuleTree, DeclarationTree)
369- --package-order=NAME Causes the specified module to be ordered first. Can
370- be specified multiple times.
371- --sitemap-url Specifies the base URL used for sitemap generation
372- --module-sort=MODE The sort order used for lists of modules
373- --decl-sort=MODE The sort order used for declaration lists
374- --file-name-style=STY Sets a translation style for symbol names to file
375- names. Use this instead of --lowercase-name.
376- Possible values for STY:
377- unaltered, camelCase, pascalCase, lowerCase,
378- upperCase, lowerUnderscored, upperUnderscored
379- --lowercase-names DEPRECATED: Outputs all file names in lower case.
380- This option is useful on case insensitive file
381- systems.
382- --enum-member-pages Generate a single page per enum member
383- --html-style=STYLE Sets the HTML output style, either pretty (default)
384- compact or .
385- --hyphenate hyphenate text
386- -h --help Show this help
387-
388- The following values can be used as sorting modes: none, name, protectionName,
389- protectionInheritanceName
390- ` , args[0 ]);
391- break ;
392- case " filter" :
393- writefln(
394- ` Usage: %s filter <ddocx-input-file> [options]
395- --ex=PREFIX Exclude modules with prefix
396- --in=PREFIX Force include of modules with prefix
397- --min-protection=PROT Remove items with lower protection level than
398- specified.
399- PROT can be: Public, Protected, Package, Private
400- --only-documented Remove undocumented entities.
401- --keep-unittests Do not remove unit tests from documentation.
402- Implies --keep-internals.
403- --keep-internals Do not remove symbols starting with two underscores.
404- --unittest-examples Add documented unit tests as examples to the
405- preceding declaration (deprecated, enabled by
406- default)
407- --no-unittest-examples Don't convert documented unit tests to examples
408- -h --help Show this help
409- ` , args[0 ]);
410- }
411- if ( args.length < 2 ){
412- } else {
413-
414- }
415- }
416-
203+ // from ddox
417204private string extractUnittestSourceCode (Json decl, Json mod)
418205{
419206 auto filename = mod[" file" ].get ! string ();
0 commit comments