aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sdp/meta/metadoc.d
blob: 129e53c86199d27ae9005924f1a87f23f2751a02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
module sdp.meta.metadoc;
template SiSUabstraction() {
  import
    std.getopt,
    std.file,
    std.path,
    std.process;
  import
    sdp.meta,
    sdp.meta.metadoc_summary,
    sdp.meta.metadoc_from_src,
    sdp.meta.conf_make_meta,
    // sdp.meta.conf_make_meta_native,
    sdp.meta.conf_make_meta_sdlang,
    sdp.meta.conf_make_meta_composite,
    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_file_list, image_list }
  enum makeMeta { make, meta }
  enum docAbst  { doc_abstraction, section_keys, segnames, segnames_0_4, images }
  static auto rgx = Rgx();
  auto SiSUabstraction(E,O,M)(
    E _env,
    O _opt_action,
    M _manifest,
  ){
    auto sdl_root_config_document = configReadDoc!()(_manifest, _env); // document config file
    auto sdl_root_config_local_site = configReadSite!()(_manifest, _env); // local site config
    auto conf_files_composite_make = confFilesSDLtoStruct!()(sdl_root_config_document, sdl_root_config_local_site);
    /+ ↓ read file (filename with path) +/
    /+ ↓ file tuple of header and content +/
    debug(steps) {
      writeln(__LINE__, ":", __FILE__,
        ": step1 commence → (get document header & body & insert file list & if needed image list)"
      );
    }
    auto _header_body_insertfilelist_imagelist
      = SiSUrawMarkupContent!()(_opt_action, _manifest.src.path_and_fn);
    static assert(!isTypeTuple!(_header_body_insertfilelist_imagelist));
    static assert(_header_body_insertfilelist_imagelist.length==4);
    debug(steps) {
      writeln(__LINE__, ":", __FILE__, ": step1 complete");
    }
    debug(header_and_body) {
      writeln(header);
      writeln(_header_body_insertfilelist_imagelist.length);
      writeln(_header_body_insertfilelist_imagelist.length[headBody.body_content][0]);
    }
    /+ ↓ split header into make and meta +/
    debug(steps) {
      writeln(__LINE__, ":", __FILE__,
        ": step2 commence → (doc header: make & meta as struct)"
       );
    }
    auto _make_and_meta_struct
      = docHeaderMakeAndMetaTupExtractAndConvertToStruct!()(
        conf_files_composite_make,
        _header_body_insertfilelist_imagelist[headBody.header]
      ); // breakage ...
    debug(steps) {
      writeln(__LINE__, ":", __FILE__, ": step2 complete");
    }
    /+ ↓ document abstraction: process document, return abstraction as tuple +/
    debug(steps) {
      writeln(__LINE__, ":", __FILE__, ": step3 commence → (document abstraction (da); da keys; segnames; doc_matters)");
    }
    auto da = SiSUdocAbstraction!()(
      _header_body_insertfilelist_imagelist[headBody.body_content],
      _make_and_meta_struct,
      _opt_action,
    );
    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];
    debug(steps) {
      writeln(__LINE__, ":", __FILE__, ": step3 complete");
    }
    debug(steps) {
      writeln(__LINE__, ":", __FILE__, ": step4 commence → (doc_matters)");
    }
    struct DocumentMatters {
      auto conf_make_meta() { // TODO meld with all make instructions
        auto _k = _make_and_meta_struct;
        return _k;
      }
      auto env() {
        struct Env_ {
          auto pwd() {
            return _manifest.env.pwd;
          }
          auto home() {
            return _manifest.env.home;
          }
        }
        return Env_();
      }
      auto opt() {
        struct Opt_ {
          auto action() {
            /+ getopt options, commandline instructions, raw
             - processing instructions --epub --html etc.
             - command line config instructions --output-path
            +/
            return _opt_action;
          }
        }
        return Opt_();
      }
      auto src() {
        struct SRC_ {
          auto is_pod() {
            return _manifest.src.is_pod;
          }
          auto filename() {
            return _manifest.src.filename;
          }
          auto language() {
            return _manifest.src.lng;
          }
          auto path_info() {
            auto _k = SiSUpathsSRC!()(_manifest.env.pwd, _manifest.src.file_with_absolute_path); // would like (to have and use) relative path
            return _k;
          }
          auto file_with_absolute_path() {
            auto _k = _manifest.src.file_with_absolute_path;
            return _k;
          }
          auto absolute_path_to_src() {
            auto _k = _manifest.src.absolute_path_to_src;
            return _k;
          }
          auto base_dir() {
            auto _k = _manifest.src.base_dir;
            return _k;
          }
          auto base_parent_dir_path() {
            auto _k = _manifest.src.base_parent_dir_path;
            return _k;
          }
          auto base_dir_path() {
            auto _k = _manifest.src.base_dir_path;
            return _k;
          }
          auto media_dir_path() {
            auto _k = _manifest.src.media_dir_path;
            return _k;
          }
          auto base_parent_dir() {
            auto _k = _manifest.src.base_parent_dir;
            return _k;
          }
          auto file_insert_list() {
            string[] _k = _header_body_insertfilelist_imagelist[headBody.insert_file_list];
            return _k;
          }
          auto image_list() {
            return _images;
          }
        }
        return SRC_();
      }
      auto pod() {
        struct Pod_ {
          auto src_is_pod() {
            return _manifest.pod.src_is_pod;
          }
          auto manifest_list_of_filenames() {
            return _manifest.pod.manifest_list_of_filenames;
          }
          auto manifest_list_of_languages() {
            return _manifest.pod.manifest_list_of_languages;
          }
          auto manifest_filename() {
            return _manifest.pod.manifest_filename;
          }
          auto manifest_path() {
            return _manifest.pod.manifest_path;
          }
          auto manifest_file_with_path() {
            return _manifest.pod.manifest_file_with_path;
          }
          auto config_dirs() {
            return _manifest.pod.config_dirs;
          }
          auto image_dirs() {
            return _manifest.pod.image_dirs;
          }
        }
        return Pod_();
      }
      auto xml() {
        struct XML_ {
          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;
          }
        }
        return XML_();
      }
      auto output_path() {
        return _manifest.output.path;
      }
    }
    auto doc_matters = DocumentMatters();
    debug(steps) {
      writeln(__LINE__, ":", __FILE__, ": step4 complete");
    }
    auto t = tuple(doc_abstraction, doc_matters);
    static assert(t.length==2);
    return t;
  }
}