Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
],
"dependencies": {
"vibe-d": "~>0.7.22",
"libdparse": {"optional": true, "version": "~>0.2.0"}
"libdparse": {"optional": true, "version": "~>0.2.0"},
"hyphenate": "~>1.1.0"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just a single module and a pattern file, so I thought it wasn't worth the effort to handle Have_hyphenate everywhere (in particular b/c it's a command line option).

},
"versions": ["JsonLineNumbers"],
"configurations": [
Expand Down
5 changes: 3 additions & 2 deletions dub.selections.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
"libevent": "2.0.1+2.0.16",
"libev": "5.0.0+4.04",
"openssl": "1.1.4+1.0.1g",
"libdparse": "0.2.1",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding this effectively would make libdparse non-optional when buillding DDOX directly, but I guess we can count on libdparse enough to make it non-optional (I'll have a second look at #104 and merge it next, including the actual non-optional change there).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, it's too easy to overlook this.
I should fix dub to at least always output a stable order.

"memutils": "0.4.3",
"vibe-d": "0.7.26",
"libasync": "0.7.5",
"libdparse": "0.2.1"
"hyphenate": "1.1.0",
"libasync": "0.7.5"
}
}
35 changes: 33 additions & 2 deletions source/ddox/ddoc.d
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ module ddox.ddoc;
import vibe.core.log;
import vibe.utils.string;

import hyphenate : Hyphenator;

import std.algorithm : canFind, countUntil, map, min, remove;
import std.array;
import std.conv;
Expand Down Expand Up @@ -174,6 +176,21 @@ void setOverrideDdocMacroFiles(string[] filenames)
}


/**
Enable hyphenation of doc text.
*/
void enableHyphenation()
{
s_hyphenator = Hyphenator(import("hyphen.tex")); // en-US
s_enableHyphenation = true;
}


void hyphenate(R)(in char[] word, R orng)
{
s_hyphenator.hyphenate(word, "\­", s => orng.put(s));
}

/**
Holds a DDOC comment and formats it sectionwise as HTML.
*/
Expand Down Expand Up @@ -352,6 +369,8 @@ private {
immutable string[string] s_standardMacros;
string[string] s_defaultMacros;
string[string] s_overrideMacros;
bool s_enableHyphenation;
Hyphenator s_hyphenator;
}

/// private
Expand Down Expand Up @@ -514,7 +533,13 @@ private void renderTextLine(R)(ref R dst, string line, DdocContext context)
case '_':
line = line[1 .. $];
auto ident = skipIdent(line);
if( ident.length ) dst.put(ident);
if( ident.length )
{
if (s_enableHyphenation && !inCode)
hyphenate(ident, dst);
else
dst.put(ident);
}
else dst.put('_');
break;
case '.':
Expand Down Expand Up @@ -545,7 +570,13 @@ private void renderTextLine(R)(ref R dst, string line, DdocContext context)
dst.put(ident);
if (!inCode) dst.put("</code>");
if( link != "#" ) dst.put("</a>");
} else dst.put(ident.replace("._", "."));
} else {
ident = ident.replace("._", ".");
if (s_enableHyphenation && !inCode)
hyphenate(ident, dst);
else
dst.put(ident);
}
break;
}
}
Expand Down
23 changes: 14 additions & 9 deletions source/ddox/main.d
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,20 @@ int setupGeneratorInput(ref string[] args, out GeneratorSettings gensettings, ou
MethodStyle file_name_style = MethodStyle.unaltered;
SortMode modsort = SortMode.protectionName;
SortMode declsort = SortMode.protectionInheritanceName;
bool lowercasenames = false;
bool lowercasenames;
bool hyphenate;
getopt(args,
//config.passThrough,
"std-macros", &macrofiles,
"override-macros", &overridemacrofiles,
"navigation-type", &navtype,
"package-order", &pack_order,
"sitemap-url", &sitemapurl,
"decl-sort", &declsort,
"file-name-style", &file_name_style,
"hyphenate", &hyphenate,
"lowercase-names", &lowercasenames,
"module-sort", &modsort,
"decl-sort", &declsort
"navigation-type", &navtype,
"override-macros", &overridemacrofiles,
"package-order", &pack_order,
"sitemap-url", &sitemapurl,
"std-macros", &macrofiles,
);

if (lowercasenames) file_name_style = MethodStyle.lowerCase;
Expand All @@ -143,6 +145,7 @@ int setupGeneratorInput(ref string[] args, out GeneratorSettings gensettings, ou

setDefaultDdocMacroFiles(macrofiles);
setOverrideDdocMacroFiles(overridemacrofiles);
if (hyphenate) enableHyphenation();

// parse the json output file
auto docsettings = new DdoxSettings;
Expand Down Expand Up @@ -204,7 +207,7 @@ int cmdFilterDocs(string[] args)
if( parent.type != Json.Type.Object || parent.kind.opt!string() != "template" || templateName(parent) != json.name.opt!string() )
return Json.undefined;
}

Protection prot = Protection.Public;
if( auto p = "protection" in json ){
switch(p.get!string){
Expand Down Expand Up @@ -238,7 +241,7 @@ int cmdFilterDocs(string[] args)
return Json.undefined;
}
}

if (!keepinternals && is_internal) return Json.undefined;

if (!keeputests && is_unittest) return Json.undefined;
Expand Down Expand Up @@ -351,6 +354,7 @@ Use <COMMAND> -h|--help to get detailed usage information for a command.
--module-sort=MODE The sort order used for lists of modules
--decl-sort=MODE The sort order used for declaration lists
--web-file-dir=DIR Make files from dir available on the served site
--hyphenate hyphenate text
-h --help Show this help

The following values can be used as sorting modes: none, name, protectionName,
Expand Down Expand Up @@ -378,6 +382,7 @@ protectionInheritanceName
--lowercase-names DEPRECATED: Outputs all file names in lower case.
This option is useful on case insensitive file
systems.
--hyphenate hyphenate text
-h --help Show this help

The following values can be used as sorting modes: none, name, protectionName,
Expand Down