flashtrace 0.6.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,6 +24,9 @@ var cLike = { line: ["//"], block: [["/*", "*/"]] };
24
24
  var cLikeNested = { line: ["//"], block: [["/*", "*/", true]] };
25
25
  var php = { line: ["//", "#"], block: [["/*", "*/"]] };
26
26
  var hash = { line: ["#"], block: [] };
27
+ var coffee = { line: ["#"], block: [["###", "###"]] };
28
+ var julia = { line: ["#"], block: [["#=", "=#", true]] };
29
+ var nim = { line: ["#"], block: [["#[", "]#", true], ["##[", "]##", true]] };
27
30
  var powershell = { line: ["#"], block: [["<#", "#>"]] };
28
31
  var sql = { line: ["--"], block: [["/*", "*/"]] };
29
32
  var lua = { line: ["--"], block: [["--[[", "]]"]] };
@@ -32,6 +35,7 @@ var css = { line: [], block: [["/*", "*/"]] };
32
35
  var xml = { line: [], block: [["<!--", "-->"]] };
33
36
  var none = { line: [], block: [] };
34
37
  var semicolon = { line: [";"], block: [] };
38
+ var scheme = { line: [";"], block: [["#|", "|#", true]] };
35
39
  var percent = { line: ["%"], block: [] };
36
40
  var dashLine = { line: ["--"], block: [] };
37
41
  var ml = { line: [], block: [["(*", "*)", true]] };
@@ -46,7 +50,7 @@ function scriptGrammar(tag) {
46
50
  const type = attrOf(tag, "type");
47
51
  if (/json|importmap/.test(type)) return none;
48
52
  if (/template|html/.test(type)) return xml;
49
- if (/coffee/.test(attrOf(tag, "lang"))) return hash;
53
+ if (/coffee/.test(attrOf(tag, "lang"))) return coffee;
50
54
  return cLike;
51
55
  }
52
56
  function styleGrammar(tag) {
@@ -102,11 +106,12 @@ var BY_EXT = {
102
106
  ".ex": hash,
103
107
  ".exs": hash,
104
108
  ".tcl": hash,
105
- ".jl": hash,
106
- ".nim": hash,
107
109
  ".graphql": hash,
108
110
  ".gql": hash,
109
- ".coffee": hash,
111
+ // hash line comments plus a block pair of their own
112
+ ".jl": julia,
113
+ ".nim": nim,
114
+ ".coffee": coffee,
110
115
  ".ps1": powershell,
111
116
  ".psm1": powershell,
112
117
  ".tf": hcl,
@@ -119,8 +124,10 @@ var BY_EXT = {
119
124
  ".edn": semicolon,
120
125
  ".el": semicolon,
121
126
  ".lisp": semicolon,
122
- ".scm": semicolon,
123
- ".ss": semicolon,
127
+ // Scheme/Racket: ; lines plus nestable #| |# blocks
128
+ ".scm": scheme,
129
+ ".ss": scheme,
130
+ ".rkt": scheme,
124
131
  // percent (Erlang, LaTeX)
125
132
  ".erl": percent,
126
133
  ".hrl": percent,
@@ -296,6 +303,7 @@ var DEF_RE = new RegExp(String.raw`^\s*\`${ID_SRC}\`\s*$`);
296
303
  var HEADING_RE = /^(#{1,6})\s+(\S(?:.*\S)?)\s*$/;
297
304
  var KEYWORD_RE = /^(Needs|Covers|Tags):\s*((?:\S.*)?)$/;
298
305
  var BULLET_RE = /^\s*[-*+]\s+(\S(?:.*\S)?)\s*$/;
306
+ var DELIM_CELL_RE = /^:?-+:?$/;
299
307
  var FORWARD_LINE_RE = new RegExp(String.raw`^\s*(\`?)${FORWARD_SRC}\1\s*$`);
300
308
  var isBoundary = (l) => DEF_RE.test(l) || HEADING_RE.test(l);
301
309
  function takeForward(line, file, n, forwards) {
@@ -325,6 +333,34 @@ function keywordEntries(lines, j, inline) {
325
333
  }
326
334
  return { entries, j };
327
335
  }
336
+ function rowCells(line) {
337
+ let s = line.trim();
338
+ if (!s.includes("|")) return null;
339
+ if (s.startsWith("|")) s = s.slice(1);
340
+ if (s.endsWith("|")) s = s.slice(0, -1);
341
+ return s.split("|").map((c) => c.trim());
342
+ }
343
+ function takeKeywordTable(lines, j, item, file, problems) {
344
+ const header = rowCells(lines[j]);
345
+ if (!header) return null;
346
+ const columns = [];
347
+ header.forEach((cell, col) => {
348
+ if (cell === "Needs" || cell === "Covers" || cell === "Tags") columns.push([col, cell]);
349
+ });
350
+ if (columns.length === 0) return null;
351
+ const delim = j + 1 < lines.length ? rowCells(lines[j + 1]) : null;
352
+ if (delim?.length !== header.length || !delim.every((c) => DELIM_CELL_RE.test(c))) return null;
353
+ j++;
354
+ while (j + 1 < lines.length && !isBoundary(lines[j + 1])) {
355
+ const cells = rowCells(lines[j + 1]);
356
+ if (!cells) break;
357
+ j++;
358
+ for (const [col, keyword] of columns) {
359
+ if (cells[col]) applyKeyword(item, keyword, [cells[col]], file, j + 1, problems);
360
+ }
361
+ }
362
+ return j;
363
+ }
328
364
  function applyKeyword(item, keyword, entries, file, kwLine, problems) {
329
365
  if (keyword === "Tags") {
330
366
  item.tags.push(...entries);
@@ -353,11 +389,15 @@ function parseItemBody(lines, start, item, file, problems, forwards) {
353
389
  continue;
354
390
  }
355
391
  const kw = line.match(KEYWORD_RE);
392
+ const tableEnd = kw ? null : takeKeywordTable(lines, j, item, file, problems);
356
393
  if (kw) {
357
394
  descDone = true;
358
395
  const collected = keywordEntries(lines, j, kw[2]);
359
396
  applyKeyword(item, kw[1], collected.entries, file, j + 1, problems);
360
397
  j = collected.j;
398
+ } else if (tableEnd !== null) {
399
+ descDone = true;
400
+ j = tableEnd;
361
401
  } else if (line.trim() === "") {
362
402
  if (item.description.length > 0) descDone = true;
363
403
  } else if (!descDone) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flashtrace",
3
- "version": "0.6.0",
3
+ "version": "0.7.1",
4
4
  "description": "Lightning-fast, reference-based requirement tracing that works anywhere.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {