diff options
author | Ralph Amissah <ralph@amissah.com> | 2018-03-02 17:36:21 -0500 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2019-04-10 15:14:14 -0400 |
commit | 0524cd606d45ecc6ee52dc7c8f1655398c75712c (patch) | |
tree | 9aa65bf1ead450df126251ab53ad06480a373067 /src/sdp/meta | |
parent | conf, make, meta, init and tidy substitution (diff) |
make auto numbering related
Diffstat (limited to 'src/sdp/meta')
-rw-r--r-- | src/sdp/meta/conf_make_meta_json.d | 44 | ||||
-rw-r--r-- | src/sdp/meta/conf_make_meta_structs.d | 19 | ||||
-rw-r--r-- | src/sdp/meta/metadoc_from_src.d | 128 | ||||
-rw-r--r-- | src/sdp/meta/metadoc_summary.d | 6 |
4 files changed, 104 insertions, 93 deletions
diff --git a/src/sdp/meta/conf_make_meta_json.d b/src/sdp/meta/conf_make_meta_json.d index abb9b46..e192c70 100644 --- a/src/sdp/meta/conf_make_meta_json.d +++ b/src/sdp/meta/conf_make_meta_json.d @@ -98,15 +98,46 @@ static template contentJSONtoSiSUstruct() { ) { _struct_composite.make_str.italics = _json.object["make"]["italics"].str; } - if ("num_top" in _json.object["make"] - && (_json.object["make"]["num_top"].type().to!string == "STRING") - ) { - _struct_composite.make_str.num_top = _json.object["make"]["num_top"].str; + if ("auto_num_top_at_level" in _json.object["make"] // str == A - D, 1 - 4 + && (_json.object["make"]["auto_num_top_at_level"].type().to!string == "STRING") + ) { + _struct_composite.make_str.auto_num_top_at_level = _json.object["make"]["auto_num_top_at_level"].str; + switch (_json.object["make"]["auto_num_top_at_level"].str) { + case "A": + break; + case "B": + _struct_composite.make_str.auto_num_top_lv = 1; + break; + case "C": + _struct_composite.make_str.auto_num_top_lv = 2; + break; + case "D": + _struct_composite.make_str.auto_num_top_lv = 3; + break; + case "1": + _struct_composite.make_str.auto_num_top_lv = 4; + break; + case "2": + _struct_composite.make_str.auto_num_top_lv = 5; + break; + case "3": + _struct_composite.make_str.auto_num_top_lv = 6; + break; + case "4": + _struct_composite.make_str.auto_num_top_lv = 7; + break; + default: + break; + } } if ("num_depth" in _json.object["make"] + && (_json.object["make"]["num_depth"].type().to!string == "INTEGER") + ) { + _struct_composite.make_str.num_depth = _json.object["make"]["num_depth"].integer.to!int; + } else if ("num_depth" in _json.object["make"] && (_json.object["make"]["num_depth"].type().to!string == "STRING") ) { - _struct_composite.make_str.num_depth = _json.object["num_depth"][""].str; + _struct_composite.make_str.num_depth = _json.object["make"]["num_depth"].str.to!int; } if ("substitute" in _json.object["make"]) { string[][] _sub; @@ -147,7 +178,8 @@ static template contentJSONtoSiSUstruct() { _struct_composite.make.home_button_image = _mk.home_button_image(_struct_composite.make_str.home_button_image); _struct_composite.make.home_button_text = _mk.home_button_text(_struct_composite.make_str.home_button_text); _struct_composite.make.italics = _mk.italics(_struct_composite.make_str.italics); - _struct_composite.make.num_top = _mk.num_top(_struct_composite.make_str.num_top); + _struct_composite.make.auto_num_top_at_level = _mk.auto_num_top_at_level(_struct_composite.make_str.auto_num_top_at_level); + _struct_composite.make.auto_num_top_lv = _mk.auto_num_top_lv(_struct_composite.make_str.auto_num_top_lv); _struct_composite.make.num_depth = _mk.num_depth(_struct_composite.make_str.num_depth); _struct_composite.make.substitute = _mk.substitute(_struct_composite.make_str.substitute); _struct_composite.make.texpdf_font = _mk.texpdf_font(_struct_composite.make_str.texpdf_font); diff --git a/src/sdp/meta/conf_make_meta_structs.d b/src/sdp/meta/conf_make_meta_structs.d index add72d6..41af6ba 100644 --- a/src/sdp/meta/conf_make_meta_structs.d +++ b/src/sdp/meta/conf_make_meta_structs.d @@ -20,8 +20,9 @@ struct ConfCompositeMakeStr { string home_button_image; string home_button_text; string italics; - string num_top; - string num_depth; + string auto_num_top_at_level; + int auto_num_top_lv = 9; + int num_depth = 2; string[][] substitute; string texpdf_font; } @@ -68,10 +69,13 @@ struct confCompositeMakeBuild { } return _out; } - auto num_top(string _mk) { + auto auto_num_top_at_level(string _mk) { return _mk; } - auto num_depth(string _mk) { + auto auto_num_top_lv(int _mk) { + return _mk; + } + auto num_depth(int _mk) { return _mk; } auto substitute(string[][] _mk) { @@ -92,8 +96,9 @@ struct ConfCompositeMakeInit { string home_button_image; string home_button_text; string[] italics; - string num_top; - string num_depth; + string auto_num_top_at_level; + int auto_num_top_lv = 9; + int num_depth = 2; string[][] substitute; string texpdf_font; } @@ -243,7 +248,7 @@ static auto ptr_head_sub_make "home_button_image", "home_button_text", "footer", "headings", - "num_top", "num_depth", + "auto_num_top_at_level", "auto_num_top_lv", "num_depth", "breaks", "substitute", "bold", diff --git a/src/sdp/meta/metadoc_from_src.d b/src/sdp/meta/metadoc_from_src.d index 627b37a..6035825 100644 --- a/src/sdp/meta/metadoc_from_src.d +++ b/src/sdp/meta/metadoc_from_src.d @@ -4350,113 +4350,83 @@ template SiSUdocAbstraction() { static assert(is(typeof(munge_) == string)); static assert(is(typeof(obj_) == string[string])); } - if (conf_make_meta.make.num_top.length > 0) { - static __gshared int heading_num_top_level=9; - static __gshared int heading_num_depth=2; - static __gshared int heading_num_0 = 0; - static __gshared int heading_num_1 = 0; - static __gshared int heading_num_2 = 0; - static __gshared int heading_num_3 = 0; - static __gshared string heading_number_auto_composite = ""; - if (heading_num_top_level==9) { - if (conf_make_meta.make.num_depth.length > 0) { - heading_num_depth = conf_make_meta.make.num_depth.to!uint; - } - switch (conf_make_meta.make.num_top) { - case "A": - break; - case "B": - heading_num_top_level=1; - break; - case "C": - heading_num_top_level=2; - break; - case "D": - heading_num_top_level=3; - break; - case "1": - heading_num_top_level=4; - break; - case "2": - heading_num_top_level=5; - break; - case "3": - heading_num_top_level=6; - break; - case "4": - heading_num_top_level=7; - break; - default: - break; - } + static __gshared int[] heading_num = [ 0, 0, 0, 0 ]; + static __gshared string heading_number_auto_composite = ""; + if (conf_make_meta.make.auto_num_top_lv) { + if (obj_["lev_markup_number"].to!int == 0) { + heading_num[0] = 0; + heading_num[1] = 0; + heading_num[2] = 0; + heading_num[3] = 0; + heading_number_auto_composite = ""; } /+ num_depth minimum 0 (1.) default 2 (1.1.1) max 3 (1.1.1.1) implement +/ if ( - heading_num_top_level + conf_make_meta.make.auto_num_top_lv > obj_["lev_markup_number"].to!uint ) { - heading_num_1 = 0; - heading_num_2 = 0; - heading_num_3 = 0; + heading_num[1] = 0; + heading_num[2] = 0; + heading_num[3] = 0; } else if ( - heading_num_top_level + conf_make_meta.make.auto_num_top_lv == obj_["lev_markup_number"].to!uint ) { - heading_num_0 ++; - heading_num_1 = 0; - heading_num_2 = 0; - heading_num_3 = 0; + heading_num[0] ++; + heading_num[1] = 0; + heading_num[2] = 0; + heading_num[3] = 0; } else if ( - heading_num_top_level + conf_make_meta.make.auto_num_top_lv == (obj_["lev_markup_number"].to!uint - 1) ) { - heading_num_1 ++; - heading_num_2 = 0; - heading_num_3 = 0; + heading_num[1] ++; + heading_num[2] = 0; + heading_num[3] = 0; } else if ( - heading_num_top_level + conf_make_meta.make.auto_num_top_lv == (obj_["lev_markup_number"].to!uint - 2) ) { - heading_num_2 ++; - heading_num_3 = 0; + heading_num[2] ++; + heading_num[3] = 0; } else if ( - heading_num_top_level + conf_make_meta.make.auto_num_top_lv == (obj_["lev_markup_number"].to!uint - 3) ) { - heading_num_3 ++; + heading_num[3] ++; } - if (heading_num_3 > 0) { + if (heading_num[3] > 0) { heading_number_auto_composite - = (heading_num_depth == 3) - ? ( heading_num_0.to!string ~ "." - ~ heading_num_1.to!string ~ "." - ~ heading_num_2.to!string ~ "." - ~ heading_num_3.to!string + = (conf_make_meta.make.num_depth.to!uint == 3) + ? ( heading_num[0].to!string ~ "." + ~ heading_num[1].to!string ~ "." + ~ heading_num[2].to!string ~ "." + ~ heading_num[3].to!string ) : ""; - } else if (heading_num_2 > 0) { + } else if (heading_num[2] > 0) { heading_number_auto_composite - = ((heading_num_depth >= 2) - && (heading_num_depth <= 3)) - ? ( heading_num_0.to!string ~ "." - ~ heading_num_1.to!string ~ "." - ~ heading_num_2.to!string + = ((conf_make_meta.make.num_depth.to!uint >= 2) + && (conf_make_meta.make.num_depth.to!uint <= 3)) + ? ( heading_num[0].to!string ~ "." + ~ heading_num[1].to!string ~ "." + ~ heading_num[2].to!string ) : ""; - } else if (heading_num_1 > 0) { + } else if (heading_num[1] > 0) { heading_number_auto_composite - = ((heading_num_depth >= 1) - && (heading_num_depth <= 3)) - ? ( heading_num_0.to!string ~ "." - ~ heading_num_1.to!string + = ((conf_make_meta.make.num_depth.to!uint >= 1) + && (conf_make_meta.make.num_depth.to!uint <= 3)) + ? ( heading_num[0].to!string ~ "." + ~ heading_num[1].to!string ) : ""; - } else if (heading_num_0 > 0) { + } else if (heading_num[0] > 0) { heading_number_auto_composite - = ((heading_num_depth >= 0) - && (heading_num_depth <= 3)) - ? (heading_num_0.to!string) + = ((conf_make_meta.make.num_depth.to!uint >= 0) + && (conf_make_meta.make.num_depth.to!uint <= 3)) + ? (heading_num[0].to!string) : ""; } else { heading_number_auto_composite = ""; @@ -4465,7 +4435,7 @@ template SiSUdocAbstraction() { writeln(heading_number_auto_composite); } if ((!empty(heading_number_auto_composite)) - && (obj_["lev_markup_number"].to!uint >= heading_num_top_level)) { + && (obj_["lev_markup_number"].to!uint >= conf_make_meta.make.auto_num_top_lv)) { munge_=(munge_) .replaceFirst(rgx.heading, "$1~$2 " ~ heading_number_auto_composite ~ ". ") diff --git a/src/sdp/meta/metadoc_summary.d b/src/sdp/meta/metadoc_summary.d index ac2477e..7db1b23 100644 --- a/src/sdp/meta/metadoc_summary.d +++ b/src/sdp/meta/metadoc_summary.d @@ -52,7 +52,7 @@ template SiSUabstractionSummary() { ? char_repeat_number : min_repeat_number; writefln( - "%s\n\"%s\", %s\n%s\n%s\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n(%s: %s)\n%s", + "%s\n\"%s\", %s\n%s\n%s\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n(%s: %s)\n%s", markup.repeat_character_by_number_provided("-", char_repeat_number), doc_matters.conf_make_meta.meta.title_full, doc_matters.conf_make_meta.meta.creator_author, @@ -88,6 +88,10 @@ template SiSUabstractionSummary() { (doc_abstraction["blurb"].length > 1) ? (to!int(doc_abstraction["blurb"].length)) : 0, + "number of segments:", + (doc_matters.xml.segnames.length > 1) + ? (to!int(doc_matters.xml.segnames.length)) + : 0, __FILE__, __LINE__, markup.repeat_character_by_number_provided("-", min_repeat_number), |