Skip to content

Commit

Permalink
chmgen: Make HTML root configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberShadow committed Feb 14, 2015
1 parent 7ad488d commit a2183f6
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions chmgen.d
Expand Up @@ -13,7 +13,7 @@ import std.string;
import std.regex;
import std.path;

enum ROOT = `.`;
string docRoot = `.`;

// ********************************************************************

Expand Down Expand Up @@ -124,6 +124,7 @@ void main(string[] args)

getopt(args,
"only-tags", &onlyTags,
"root", &docRoot,
);

bool chm = !onlyTags;
Expand All @@ -135,24 +136,24 @@ void main(string[] args)
mkdirRecurse(`chm/files`);
}

enforce(exists(ROOT ~ `/phobos/index.html`),
enforce(exists(docRoot ~ `/phobos/index.html`),
`Phobos documentation not present. Please place Phobos documentation HTML files into the "phobos" subdirectory.`);

string[] files = chain(
dirEntries(ROOT ~ `/` , "*.html", SpanMode.shallow),
dirEntries(ROOT ~ `/phobos/`, "*.html", SpanMode.shallow),
// dirEntries(ROOT ~ `/js/` , SpanMode.shallow),
dirEntries(ROOT ~ `/css/` , SpanMode.shallow),
dirEntries(ROOT ~ `/images/`, "*.*" , SpanMode.shallow),
only(ROOT ~ `/favicon.ico`)
dirEntries(docRoot ~ `/` , "*.html", SpanMode.shallow),
dirEntries(docRoot ~ `/phobos/`, "*.html", SpanMode.shallow),
// dirEntries(docRoot ~ `/js/` , SpanMode.shallow),
dirEntries(docRoot ~ `/css/` , SpanMode.shallow),
dirEntries(docRoot ~ `/images/`, "*.*" , SpanMode.shallow),
only(docRoot ~ `/favicon.ico`)
).array();

foreach (fileName; files)
{
scope(failure) stderr.writeln("Error while processing file: ", fileName);

auto page = new Page;
fileName = page.fileName = fileName[ROOT.length+1 .. $].forwardSlashes();
fileName = page.fileName = fileName[docRoot.length+1 .. $].forwardSlashes();
pages[fileName] = page;

auto newFileName = `chm/files/` ~ fileName;
Expand Down

0 comments on commit a2183f6

Please sign in to comment.