diff options
Diffstat (limited to 'src/sdp/meta/metadoc.d')
-rw-r--r-- | src/sdp/meta/metadoc.d | 141 |
1 files changed, 141 insertions, 0 deletions
diff --git a/src/sdp/meta/metadoc.d b/src/sdp/meta/metadoc.d new file mode 100644 index 0000000..4174b67 --- /dev/null +++ b/src/sdp/meta/metadoc.d @@ -0,0 +1,141 @@ +module sdp.meta.metadoc; +template SiSUabstraction() { + /+ sdp: sisu document parser, see http://sisudoc.org +/ + import sdp.meta; + import + std.getopt, + std.process; + import + sdp.meta.metadoc_summary, + sdp.meta.metadoc_from_src, + sdp.meta.composite_make, + sdp.meta.conf_make_meta, + // sdp.meta.conf_make_meta_native, + sdp.meta.conf_make_meta_sdlang, + sdp.meta.defaults, + sdp.meta.doc_debugs, + sdp.meta.read_config_files, + sdp.meta.read_source_files, + sdp.meta.rgx, + sdp.output.hub, + sdp.output.paths_source; + mixin SiSUrgxInit; + mixin SiSUregisters; + mixin SiSUextractSDLang; + mixin SiSUnode; + mixin SiSUbiblio; + mixin SiSUrgxInitFlags; + mixin outputHub; + enum headBody { header, body_content, insert_filelist } + enum makeMeta { make, meta } + enum docAbst { doc_abstraction, section_keys, segnames, segnames_0_4, images } + auto rgx = Rgx(); + auto SiSUabstraction(Fn,O,E)(Fn fn_src, O opts, E env){ + auto sdl_root_config_share = configRead!()("config_local", env); + auto sdl_root_config_local = configRead!()("config_share", env); + auto conf_composite_static_aa = extractSDL().sdlangToAA(conf_aa_empty, sdl_root_config_share); + conf_composite_static_aa = extractSDL().sdlangToAA(conf_composite_static_aa, sdl_root_config_local); + /+ ↓ read file (filename with path) +/ + /+ ↓ file tuple of header and content +/ + auto _header_body_inserts = + SiSUrawMarkupContent!()(fn_src); + static assert(!isTypeTuple!(_header_body_inserts)); + static assert(_header_body_inserts.length==3); + debug(header_and_body) { + writeln(header); + writeln(_header_body_inserts.length); + writeln(_header_body_inserts.length[headBody.body_content][0]); + } + /+ ↓ split header into make and meta +/ + auto _make_and_meta_tup = + docHeaderMakeAndMetaTupExtractAndConvertToAA!()(conf_composite_static_aa, _header_body_inserts[headBody.header]); + static assert(!isTypeTuple!(_make_and_meta_tup)); + static assert(_make_and_meta_tup.length==2); + auto _make_config = compositeMkCnf!()( + conf_composite_static_aa, + _make_and_meta_tup[makeMeta.make], + // opts, + ); + auto _make_and_conf_composite_static_plus_docheader_aa = compositeMkCnfAA!()( + conf_aa_empty, + conf_composite_static_aa, + _make_and_meta_tup[makeMeta.make], + opts, + ); + /+ ↓ document abstraction: process document, return abstraction as tuple +/ + auto da = SiSUdocAbstraction!()( + _header_body_inserts[headBody.body_content], + _make_and_meta_tup[makeMeta.make], + _make_and_meta_tup[makeMeta.meta], + opts + ); + static assert(!isTypeTuple!(da)); + static assert(da.length==5); + auto doc_abstraction = da[docAbst.doc_abstraction]; /+ head ~ toc ~ body ~ endnotes_seg ~ glossary ~ bibliography ~ bookindex ~ blurb; +/ + auto _document_section_keys_sequenced = da[docAbst.section_keys]; + string[] _doc_html_segnames = da[docAbst.segnames]; + string[] _doc_epub_segnames_0_4 = da[docAbst.segnames_0_4]; + auto _images = da[docAbst.images]; + struct DocumentMatters { + auto keys_seq() { + /+ contains .seg & .scroll sequences +/ + auto _k = _document_section_keys_sequenced; + return _k; + } + string[] segnames() { + string[] _k = _doc_html_segnames; + return _k; + } + string[] segnames_lv_0_to_4() { + string[] _k = _doc_epub_segnames_0_4; + return _k; + } + auto dochead_meta() { + string[string][string] _k = _make_and_meta_tup[makeMeta.meta]; + return _k; + } + auto dochead_make() { + string[string][string] _k = _make_and_meta_tup[makeMeta.make]; + return _k; + } + auto source_filename() { + string _k = fn_src; + return _k; + } + auto src_path_info() { + string _pwd = env["pwd"]; + auto _k = SiSUpathsSRC!()(_pwd, fn_src); + return _k; + } + auto opt_action() { + bool[string] _k = opts; + return _k; + } + auto environment() { + auto _k = env; + return _k; + } + auto language() { + string _k; + if (auto m = fn_src.match(rgx.language_code_and_filename)) { + _k = m.captures[1]; + } else { + _k = "en"; + } + return _k; + } + auto file_insert_list() { + string[] _k = _header_body_inserts[headBody.insert_filelist]; + return _k; + } + auto image_list() { + auto _k = _images; + return _k; + } + } + auto doc_matters = DocumentMatters(); + auto t = tuple(doc_abstraction, doc_matters); + static assert(t.length==2); + return t; + } +} |