pict-docuserve 0.0.27 → 0.0.29

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pict-docuserve",
3
- "version": "0.0.27",
3
+ "version": "0.0.29",
4
4
  "description": "Pict Documentation Server - A single-page documentation viewer built on Pict",
5
5
  "main": "source/Pict-Application-Docuserve.js",
6
6
  "bin": {
@@ -18,25 +18,23 @@
18
18
  "build-docs": "npx quack build && npx quack copy && node source/cli/Docuserve-CLI-Run.js inject ./docs && node example_applications/build-examples.js stage-docs",
19
19
  "serve-docs": "node source/cli/Docuserve-CLI-Run.js serve ./docs",
20
20
  "serve-examples": "node example_applications/build-examples.js",
21
- "test": "npx mocha -u tdd --exit -R spec",
22
- "tests": "npx mocha -u tdd --exit -R spec --grep",
23
- "coverage": "npx nyc --reporter=lcov --reporter=text-lcov npx mocha -- -u tdd -R spec"
21
+ "test": "npx quack test",
22
+ "tests": "npx quack test -g",
23
+ "coverage": "npx quack coverage"
24
24
  },
25
25
  "author": "steven velozo <steven@velozo.com>",
26
26
  "license": "MIT",
27
27
  "dependencies": {
28
28
  "lunr": "^2.3.9",
29
- "pict": "^1.0.348",
30
- "pict-application": "^1.0.32",
31
- "pict-provider": "^1.0.10",
32
- "pict-section-content": "^0.0.5",
33
- "pict-service-commandlineutility": "^1.0.18",
34
- "pict-view": "^1.0.66"
29
+ "pict": "^1.0.355",
30
+ "pict-application": "^1.0.33",
31
+ "pict-provider": "^1.0.12",
32
+ "pict-section-content": "^0.0.7",
33
+ "pict-service-commandlineutility": "^1.0.19",
34
+ "pict-view": "^1.0.67"
35
35
  },
36
36
  "devDependencies": {
37
- "chai": "^6.2.2",
38
- "mocha": "^11.7.5",
39
- "quackage": "^1.0.51"
37
+ "quackage": "^1.0.59"
40
38
  },
41
39
  "copyFilesSettings": {
42
40
  "whenFileExists": "overwrite"
@@ -61,7 +61,7 @@ class DocuserveApplication extends libPictApplication
61
61
  let tmpDocProvider = this.pict.providers['Docuserve-Documentation'];
62
62
  tmpDocProvider.loadCatalog(() =>
63
63
  {
64
- // Set the page title from cover.md or _topbar.md
64
+ // Set the page title from _cover.md or _topbar.md
65
65
  let tmpDocuserve = this.pict.AppData.Docuserve;
66
66
  if (tmpDocuserve.CoverLoaded && tmpDocuserve.Cover && tmpDocuserve.Cover.Title)
67
67
  {
@@ -57,10 +57,46 @@ class DocuserveDocumentationProvider extends libPictProvider
57
57
  }
58
58
 
59
59
  /**
60
- * Load all documentation data sources: catalog, cover.md, _sidebar.md.
60
+ * Create an image resolver closure for the content provider.
61
+ *
62
+ * Resolves relative image URLs against the directory of the document
63
+ * being rendered, so that images referenced with relative paths in
64
+ * markdown (e.g. `![graph](diagram.svg)`) resolve correctly even
65
+ * when the page uses hash-based routing.
66
+ *
67
+ * @param {string} pDocURL - The URL the markdown document was fetched from
68
+ * @returns {Function} An image resolver callback: (pSrc, pAlt) => resolvedSrc
69
+ */
70
+ _createImageResolver(pDocURL)
71
+ {
72
+ // Extract the directory portion of the document URL
73
+ let tmpBaseDir = '';
74
+ if (pDocURL)
75
+ {
76
+ let tmpLastSlash = pDocURL.lastIndexOf('/');
77
+ if (tmpLastSlash >= 0)
78
+ {
79
+ tmpBaseDir = pDocURL.substring(0, tmpLastSlash + 1);
80
+ }
81
+ }
82
+
83
+ return (pSrc, pAlt) =>
84
+ {
85
+ // Leave absolute URLs, data URIs, and root-relative paths unchanged
86
+ if (pSrc.match(/^https?:\/\//) || pSrc.match(/^data:/) || pSrc.match(/^\//))
87
+ {
88
+ return pSrc;
89
+ }
90
+ // Prepend the document's directory to make relative paths work
91
+ return tmpBaseDir + pSrc;
92
+ };
93
+ }
94
+
95
+ /**
96
+ * Load all documentation data sources: catalog, _cover.md, _sidebar.md.
61
97
  *
62
98
  * Loads the catalog first (it provides the fallback data), then attempts
63
- * to load cover.md and _sidebar.md in parallel. If those markdown files
99
+ * to load _cover.md and _sidebar.md in parallel. If those markdown files
64
100
  * exist they drive the splash and sidebar views; otherwise the catalog
65
101
  * data is used as a fallback.
66
102
  *
@@ -74,7 +110,7 @@ class DocuserveDocumentationProvider extends libPictProvider
74
110
 
75
111
  let tmpLoadOptionalFiles = () =>
76
112
  {
77
- // Load cover.md, _sidebar.md, _topbar.md, errorpage.md and keyword index in parallel.
113
+ // Load _cover.md, _sidebar.md, _topbar.md, errorpage.md and keyword index in parallel.
78
114
  // When all are done, if we still have no sidebar data, try to auto-discover
79
115
  // a README.md so the site works with plain markdown folders.
80
116
  let tmpPending = 5;
@@ -205,9 +241,9 @@ class DocuserveDocumentationProvider extends libPictProvider
205
241
  }
206
242
 
207
243
  /**
208
- * Fetch and parse cover.md into structured data for the splash view.
244
+ * Fetch and parse _cover.md into structured data for the splash view.
209
245
  *
210
- * The expected cover.md format follows the docsify convention:
246
+ * The expected _cover.md format follows the docsify convention:
211
247
  * # Title
212
248
  * > Tagline
213
249
  * Description paragraph text.
@@ -224,7 +260,7 @@ class DocuserveDocumentationProvider extends libPictProvider
224
260
  let tmpCallback = (typeof(fCallback) === 'function') ? fCallback : () => {};
225
261
  let tmpDocsBase = this.pict.AppData.Docuserve.DocsBaseURL || '';
226
262
 
227
- fetch(tmpDocsBase + 'cover.md')
263
+ fetch(tmpDocsBase + '_cover.md')
228
264
  .then((pResponse) =>
229
265
  {
230
266
  if (!pResponse.ok)
@@ -237,7 +273,7 @@ class DocuserveDocumentationProvider extends libPictProvider
237
273
  {
238
274
  if (!pMarkdown)
239
275
  {
240
- this.log.info('Docuserve: No cover.md found; splash will use catalog data.');
276
+ this.log.info('Docuserve: No _cover.md found; splash will use catalog data.');
241
277
  return tmpCallback();
242
278
  }
243
279
 
@@ -247,15 +283,15 @@ class DocuserveDocumentationProvider extends libPictProvider
247
283
  })
248
284
  .catch((pError) =>
249
285
  {
250
- this.log.warn(`Docuserve: Error loading cover.md: ${pError}`);
286
+ this.log.warn(`Docuserve: Error loading _cover.md: ${pError}`);
251
287
  return tmpCallback();
252
288
  });
253
289
  }
254
290
 
255
291
  /**
256
- * Parse cover.md markdown text into a structured object.
292
+ * Parse _cover.md markdown text into a structured object.
257
293
  *
258
- * @param {string} pMarkdown - Raw cover.md content
294
+ * @param {string} pMarkdown - Raw _cover.md content
259
295
  * @returns {Object} Parsed cover data
260
296
  */
261
297
  parseCover(pMarkdown)
@@ -1286,7 +1322,7 @@ class DocuserveDocumentationProvider extends libPictProvider
1286
1322
  return tmpCallback('Document not found', this.getErrorPageHTML(pURL));
1287
1323
  }
1288
1324
 
1289
- let tmpHTML = this._ContentProvider.parseMarkdown(pMarkdown, this._createLinkResolver(pCurrentGroup, pCurrentModule, pCurrentDocPath));
1325
+ let tmpHTML = this._ContentProvider.parseMarkdown(pMarkdown, this._createLinkResolver(pCurrentGroup, pCurrentModule, pCurrentDocPath), this._createImageResolver(pURL));
1290
1326
  this._ContentCache[pURL] = tmpHTML;
1291
1327
  return tmpCallback(null, tmpHTML);
1292
1328
  })
@@ -162,7 +162,7 @@ class DocusserveSplashView extends libPictView
162
162
  }
163
163
 
164
164
  /**
165
- * Render the splash screen from parsed cover.md data.
165
+ * Render the splash screen from parsed _cover.md data.
166
166
  *
167
167
  * @param {Object} pCover - The parsed cover data { Title, Tagline, Description, Highlights, Actions }
168
168
  */
@@ -212,7 +212,7 @@ class DocusserveSplashView extends libPictView
212
212
  }
213
213
 
214
214
  /**
215
- * Render the splash screen from catalog data as a fallback when cover.md
215
+ * Render the splash screen from catalog data as a fallback when _cover.md
216
216
  * is not available.
217
217
  *
218
218
  * @param {Object} pDocuserve - The AppData.Docuserve state