aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sdp/ao_output_debugs.d
blob: 3c97640faf8cee9862cb7fc20e35943aa04778d4 (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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
/+
  output debugs
  ao_output_debugs.d
+/
template SiSUoutputDebugs() {
  struct SDPoutputDebugs {
    auto abstract_doc_source_debugs(S)(
      auto ref const S         contents,
      string[][string][string] bookindex_unordered_hashes,
      JSONValue[]              biblio,
      JSONValue[string]        dochead_make,
      JSONValue[string]        dochead_meta,
      string                   fn_src,
      bool[string]             opt_action_bool
    ) {
      mixin RgxInit;
      mixin ScreenTxtColors;
      auto rgx = Rgx();
      debug(parent) {
        writefln(
          "%s:%s",
          __FILE__,
          __LINE__,
        );
        foreach (obj; contents) {
          if (obj.use == "content") {
            if (obj.is_a == "heading") {
              writefln(
                "%s%s node: %s heading: %s %s",
                scr_txt_marker["cyan"],
                obj.obj_cite_number,
                obj.node,
                obj.lev_markup_number,
                obj.object,
              );
            } else {
            }
          }
        }
      }
      debug(dumpdoc) {
        writefln(
          "%s\n%s:%s",
          "-------------------------------",
          __FILE__,
          __LINE__,
        );
        foreach (obj; contents) {
          if (obj.use == "content") {
            writefln(
              "[%s][%s]\n%s",
              obj.obj_cite_number,
              obj.is_a,
              obj.object
            );
          }
        }
      }
      debug(objects) {
        writefln(
          "%s\n%s:%s",
          "-------------------------------",
          __FILE__,
          __LINE__,
        );
        foreach (obj; contents) {
          if (obj.use == "content") {
            writefln(
              "%s* [%s][%s] %s%s",
              scr_txt_color["green"],
              obj.obj_cite_number,
              obj.is_a,
              scr_txt_color["off"],
              obj.object
            );
          }
        }
      }
      debug(headermakejson) {
        writefln(
          "%s\n%s\n%s",
          "document header, metadata & make instructions:",
          dochead_meta,
          pointer_head_main,
        );
        foreach (main_header; pointer_head_main) {
          switch (main_header) {
          case "make":
            foreach (sub_header; pointer_head_sub_make) {
              if (to!string(dochead_meta[main_header][sub_header]).length > 2) {
                writefln(
                  "%s:%s: %s",
                  main_header,
                  sub_header,
                  dochead_meta[main_header][sub_header]
                );
              }
            }
            break;
          default:
            break;
          }
        }
      }
      debug(headermetadatajson) {
        writefln(
          "%s\n%s\n%s",
          "document header, metadata & make instructions:",
          dochead_meta,
          pointer_head_main,
        );
        foreach (main_header; pointer_head_main) {
          switch (main_header) {
          case "creator":
            foreach (sub_header; pointer_head_sub_creator) {
              if (to!string(dochead_meta[main_header][sub_header]).length > 2) {
                writefln(
                  "%s:%s: %s",
                  main_header,
                  sub_header,
                  dochead_meta[main_header][sub_header]
                );
              }
            }
            break;
          case "title":
            foreach (sub_header; pointer_head_sub_title) {
              if (to!string(dochead_meta[main_header][sub_header]).length > 2) {
                writefln(
                  "%s:%s: %s",
                  main_header,
                  sub_header,
                  dochead_meta[main_header][sub_header]
                );
              }
            }
            break;
          case "rights":
            foreach (sub_header; pointer_head_sub_rights) {
              if (to!string(dochead_meta[main_header][sub_header]).length > 2) {
                writefln(
                  "%s:%s: %s",
                  main_header,
                  sub_header,
                  dochead_meta[main_header][sub_header]
                );
              }
            }
            break;
          case "date":
            foreach (sub_header; pointer_head_sub_date) {
              if (to!string(dochead_meta[main_header][sub_header]).length > 2) {
                writefln(
                  "%s:%s: %s",
                  main_header,
                  sub_header,
                  dochead_meta[main_header][sub_header]
                );
              }
            }
            break;
          case "original":
            foreach (sub_header; pointer_head_sub_original) {
              if (to!string(dochead_meta[main_header][sub_header]).length > 2) {
                writefln(
                  "%s:%s: %s",
                  main_header,
                  sub_header,
                  dochead_meta[main_header][sub_header]
                );
              }
            }
            break;
          case "classify":
            foreach (sub_header; pointer_head_sub_classify) {
              if (to!string(dochead_meta[main_header][sub_header]).length > 2) {
                writefln(
                  "%s:%s: %s",
                  main_header,
                  sub_header,
                  dochead_meta[main_header][sub_header]
                );
              }
            }
            break;
          case "identifier":
            foreach (sub_header; pointer_head_sub_identifier) {
              if (to!string(dochead_meta[main_header][sub_header]).length > 2) {
                writefln(
                  "%s:%s: %s",
                  main_header,
                  sub_header,
                  dochead_meta[main_header][sub_header]
                );
              }
            }
            break;
          case "notes":
            foreach (sub_header; pointer_head_sub_notes) {
              if (to!string(dochead_meta[main_header][sub_header]).length > 2) {
                writefln(
                  "%s:%s: %s",
                  main_header,
                  sub_header,
                  dochead_meta[main_header][sub_header]
                );
              }
            }
            break;
          case "publisher":
            foreach (sub_header; pointer_head_sub_publisher) {
              if (to!string(dochead_meta[main_header][sub_header]).length > 2) {
                writefln(
                  "%s:%s: %s",
                  main_header,
                  sub_header,
                  dochead_meta[main_header][sub_header]
                );
              }
            }
            break;
          default:
            break;
          }
        }
      }
      debug(bookindex) {
        writefln(
          "%s\n%s:%s",
          "-------------------------------",
          __FILE__,
          __LINE__,
        );
        auto bookindex = BookIndexReport();
        bookindex.bookindex_report_sorted(bookindex_unordered_hashes);
      }
      debug(summary) {
        string[string] check = [
          "last_obj_cite_number" : "NA [debug \"checkdoc\" not run]",
        ];
        debug(checkdoc) {
          foreach (obj; contents) {
            if (obj.use == "content") {
              if (!empty(obj.obj_cite_number)) {
                check["last_obj_cite_number"] = obj.obj_cite_number;
              }
            }
          }
        }
        debug(headings) {
          writefln(
            "%s\n%s:%s",
            "-------------------------------",
            __FILE__,
            __LINE__,
          );
          foreach (obj; contents) {
            if (obj.is_a == "heading") {
              writefln(
                "%s%s~ [%s] %s",
                scr_txt_marker["yellow"],
                obj.heading_attrib.lev,
                obj.obj_cite_number,
                // "[", obj["is"], "] ",
                obj.object
              );
            }
          }
        }
        writefln(
          "%s%s%s\n%s\n%s%s\n%s%s\n%s%s\n%s:%s",
          scr_txt_color["green"],
          "-------------------------------",
          scr_txt_color["off"],
          fn_src,
          "length contents array: ",
          contents.length,
          "last obj_cite_number: ",
          check["last_obj_cite_number"],
          "length bookindex: ",
          bookindex_unordered_hashes.length,
          __FILE__,
          __LINE__,
        );
        debug(checkdoc) {
          if (auto mfn=match(fn_src, rgx.src_fn)) {
            if (opt_action_bool["assertions"]) {
              switch (mfn.captures[2]) {
              case "live-manual.ssm":
                assert(check["last_obj_cite_number"] ==
                  "1019","last obj_cite_number should be: 1019 (check test, document is frequently updated)"); // ok
                break;
              case "sisu_markup.sst":
                assert(check["last_obj_cite_number"] ==
                  "297","last obj_cite_number expected to be: 297 rather than " ~ check["last_obj_cite_number"]); // ok
                // assert(check["last_obj_cite_number"] == "297","last obj_cite_number expected to be: 297 rather than " ~ check["last_obj_cite_number"]);
                // notes for first divergance study sisu headings 247 250
                // sisu has issue with code that contains heading 1~ which results in no obj_cite_number! ??
                // sisu currently has incorrect last body obj_cite_number of 294!
                // bug in sisu? attend
                break;
              // sisu-markup-samples:
              case "accelerando.charles_stross.sst":
                assert(check["last_obj_cite_number"] ==
                  "2861","last obj_cite_number expected to be: 2861 rather than " ~ check["last_obj_cite_number"]); // ok
                break;
              case "alices_adventures_in_wonderland.lewis_carroll.sst":
                assert(check["last_obj_cite_number"] ==
                  "805","last obj_cite_number expected to be: 805 rather than " ~ check["last_obj_cite_number"]); // 808
                break;
              case "autonomy_markup0.sst":
                assert(check["last_obj_cite_number"] ==
                  "77","last obj_cite_number expected to be: 77 rather than " ~ check["last_obj_cite_number"]); // ok endnotes
                // assert(check["last_obj_cite_number"] == "78","last obj_cite_number expected to be: 78 rather than " ~ check["last_obj_cite_number"]);
                break;
              case "content.cory_doctorow.sst":
                assert(check["last_obj_cite_number"] ==
                  "953","last obj_cite_number expected to be: 953 rather than " ~ check["last_obj_cite_number"]); // 1007 way off, check obj_cite_number off switches
                // assert(check["last_obj_cite_number"] == "953","last obj_cite_number expected to be: 953 rather than " ~ check["last_obj_cite_number"]);
                break;
              case "democratizing_innovation.eric_von_hippel.sst":
                // fixed ERROR! range violation, broken check! endnotes, bookindex, biblio
                // error in bookindex ... (ch1; ch6; ch8 )
                assert(check["last_obj_cite_number"] ==
                  "905","last obj_cite_number expected to be: 905 rather than " ~ check["last_obj_cite_number"]); // 911
                break;
              case "down_and_out_in_the_magic_kingdom.cory_doctorow.sst":
                assert(check["last_obj_cite_number"] ==
                  "1417","last obj_cite_number expected to be: 1417 rather than " ~ check["last_obj_cite_number"]); // 1455 check obj_cite_number off switches
                break;
              case "for_the_win.cory_doctorow.sst":
                assert(check["last_obj_cite_number"] ==
                  "3510","last obj_cite_number expected to be: 3510 rather than " ~ check["last_obj_cite_number"]); // 3569 check obj_cite_number off switches
                break;
              case "free_as_in_freedom_2.richard_stallman_and_the_free_software_revolution.sam_williams.richard_stallman.sst":
                assert(check["last_obj_cite_number"] ==
                  "1082","last obj_cite_number expected to be: 1082 rather than " ~ check["last_obj_cite_number"]); // check 1079 too few
                break;
              case "free_culture.lawrence_lessig.sst":
                assert(check["last_obj_cite_number"] ==
                  "1330","last obj_cite_number expected to be: 1330 rather than " ~ check["last_obj_cite_number"]); // 1312
                // fixed ERROR! range violation, broken check!
                // error in bookindex ... sections piracy (ch1) & property (ch10 market concentration) fixed
                break;
              case "free_for_all.peter_wayner.sst": // endnotes, bookindex, biblio
                assert(check["last_obj_cite_number"] ==
                  "1559","last obj_cite_number expected to be: 1559 rather than " ~ check["last_obj_cite_number"]); // 1560, check obj_cite_number off switches, has endnotes so 2 too many
                // assert(check["last_obj_cite_number"] == "1559","last obj_cite_number expected to be: 1559 rather than " ~ check["last_obj_cite_number"]);
                break;
              case "gpl2.fsf.sst":
                assert(check["last_obj_cite_number"] ==
                  "65","last obj_cite_number expected to be: 65 rather than " ~ check["last_obj_cite_number"]); // ok endnotes? check
                // assert(check["last_obj_cite_number"] == "66","last obj_cite_number expected to be: 66 rather than " ~ check["last_obj_cite_number"]);
                break;
              case "gpl3.fsf.sst":
                assert(check["last_obj_cite_number"] ==
                  "123","last obj_cite_number expected to be: 123 rather than " ~ check["last_obj_cite_number"]); // ok
                break;
              case "gullivers_travels.jonathan_swift.sst":
                assert(check["last_obj_cite_number"] ==
                  "668","last obj_cite_number expected to be: 668 rather than " ~ check["last_obj_cite_number"]); // 674
                break;
              case "little_brother.cory_doctorow.sst":
                assert(check["last_obj_cite_number"] ==
                  "3130","last obj_cite_number expected to be: 3130 rather than " ~ check["last_obj_cite_number"]); // 3204, check obj_cite_number off switches
                break;
              case "the_cathedral_and_the_bazaar.eric_s_raymond.sst":
                assert(check["last_obj_cite_number"] ==
                  "258","last obj_cite_number expected to be: 258 rather than " ~ check["last_obj_cite_number"]); // ok
                break;
              case "the_public_domain.james_boyle.sst":
                assert(check["last_obj_cite_number"] ==
                  "970","last obj_cite_number expected to be: 970 rather than " ~ check["last_obj_cite_number"]); // 978
                break;
              case "the_wealth_of_networks.yochai_benkler.sst": // endnotes, bookindex
                assert(check["last_obj_cite_number"] ==
                  "829","last obj_cite_number expected to be: 829 rather than " ~ check["last_obj_cite_number"]); // ok
                // assert(check["last_obj_cite_number"] == "832","last obj_cite_number expected to be: 832 rather than " ~ check["last_obj_cite_number"]);
                // has endnotes and bookindex, issue with sisu.rb
                break;
              case "through_the_looking_glass.lewis_carroll.sst":
                assert(check["last_obj_cite_number"] ==
                  "949","last obj_cite_number expected to be: 949 rather than " ~ check["last_obj_cite_number"]); // 955
                break;
              case "two_bits.christopher_kelty.sst": // endnotes, bookindex, biblio
                assert(check["last_obj_cite_number"] ==
                  "1190","last obj_cite_number expected to be: 1190 rather than " ~ check["last_obj_cite_number"]); // 1191
                // assert(check["last_obj_cite_number"] == "1193","last obj_cite_number expected to be: 1193 rather than " ~ check["last_obj_cite_number"]); // 1191 ok?
                // has endnotes and bookindex, issue with sisu.rb
                break;
                // fixed ERROR! range violation!
                // error in bookindex ... (ch3 the movement)
              case "un_contracts_international_sale_of_goods_convention_1980.sst":
                assert(check["last_obj_cite_number"] ==
                  "377","last obj_cite_number expected to be: 377 rather than " ~ check["last_obj_cite_number"]); // ok
                break;
              case "viral_spiral.david_bollier.sst": // endnotes, bookindex
                assert(check["last_obj_cite_number"] ==
                  "1078","last obj_cite_number expected to be: 1078 rather than " ~ check["last_obj_cite_number"]); // 1100
                // fixed ERROR! range violation!
                // error in bookindex ... (ch7 ... building the cc machine, an extra semi colon)
                break;
              default:
                writeln(fn_src);
                break;
              }
            }
          }
        }
      }
    }
  }
}