docula 1.7.0 → 1.9.0

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/dist/docula.d.ts CHANGED
@@ -2,6 +2,48 @@ import fs from 'node:fs';
2
2
  import http from 'node:http';
3
3
  export { Writr } from 'writr';
4
4
 
5
+ declare class DoculaConsole {
6
+ quiet: boolean;
7
+ log(message: string): void;
8
+ error(message: string): void;
9
+ warn(message: string): void;
10
+ success(message: string): void;
11
+ info(message: string): void;
12
+ step(message: string): void;
13
+ fileBuilt(filePath: string): void;
14
+ fileCopied(filePath: string): void;
15
+ serverLog(method: string, url: string, statusCode: number, durationMs?: number): void;
16
+ banner(message: string): void;
17
+ printHelp(): void;
18
+ parseProcessArgv(argv: string[]): DoculaConsoleProcess;
19
+ getCommand(argv: string[]): string | undefined;
20
+ getArguments(argv: string[]): DoculaConsoleArguments;
21
+ }
22
+ type DoculaConsoleProcess = {
23
+ argv: string[];
24
+ command: string | undefined;
25
+ args: DoculaConsoleArguments;
26
+ };
27
+ type DoculaConsoleArguments = {
28
+ sitePath: string | undefined;
29
+ templatePath: string | undefined;
30
+ template: string | undefined;
31
+ output: string | undefined;
32
+ watch: boolean;
33
+ clean: boolean;
34
+ build: boolean;
35
+ port: number | undefined;
36
+ typescript: boolean;
37
+ javascript: boolean;
38
+ overwrite: boolean;
39
+ downloadTarget: string;
40
+ };
41
+
42
+ type GithubData = {
43
+ releases: Record<string, unknown>;
44
+ contributors: Record<string, unknown>;
45
+ };
46
+
5
47
  type ApiSchemaProperty = {
6
48
  name: string;
7
49
  type: string;
@@ -87,43 +129,97 @@ type ApiSpecData = {
87
129
  securitySchemes: ApiSecurityScheme[];
88
130
  };
89
131
 
90
- declare class DoculaConsole {
91
- log(message: string): void;
92
- error(message: string): void;
93
- warn(message: string): void;
94
- success(message: string): void;
95
- info(message: string): void;
96
- step(message: string): void;
97
- fileBuilt(filePath: string): void;
98
- fileCopied(filePath: string): void;
99
- serverLog(method: string, url: string, statusCode: number, durationMs?: number): void;
100
- banner(message: string): void;
101
- printHelp(): void;
102
- parseProcessArgv(argv: string[]): DoculaConsoleProcess;
103
- getCommand(argv: string[]): string | undefined;
104
- getArguments(argv: string[]): DoculaConsoleArguments;
105
- }
106
- type DoculaConsoleProcess = {
107
- argv: string[];
108
- command: string | undefined;
109
- args: DoculaConsoleArguments;
132
+ type DoculaChangelogEntry = {
133
+ title: string;
134
+ date: string;
135
+ formattedDate: string;
136
+ tag?: string;
137
+ tagClass?: string;
138
+ slug: string;
139
+ content: string;
140
+ generatedHtml: string;
141
+ preview: string;
142
+ previewImage?: string;
143
+ urlPath: string;
144
+ lastModified: string;
110
145
  };
111
- type DoculaConsoleArguments = {
112
- sitePath: string | undefined;
113
- templatePath: string | undefined;
114
- template: string | undefined;
115
- output: string | undefined;
116
- watch: boolean;
117
- clean: boolean;
118
- build: boolean;
119
- port: number | undefined;
120
- typescript: boolean;
121
- javascript: boolean;
146
+ type DoculaData = {
147
+ siteUrl: string;
148
+ siteTitle: string;
149
+ siteDescription: string;
150
+ sitePath: string;
151
+ templatePath: string;
152
+ output: string;
153
+ githubPath?: string;
154
+ github?: GithubData;
155
+ templates?: DoculaTemplates;
156
+ hasDocuments?: boolean;
157
+ hasChangelog?: boolean;
158
+ sections?: DoculaSection[];
159
+ documents?: DoculaDocument[];
160
+ sidebarItems?: DoculaSection[];
161
+ announcement?: string;
162
+ openApiUrl?: string;
163
+ hasApi?: boolean;
164
+ apiSpec?: ApiSpecData;
165
+ changelogEntries?: DoculaChangelogEntry[];
166
+ hasReadme?: boolean;
167
+ themeMode?: string;
168
+ cookieAuth?: {
169
+ loginUrl: string;
170
+ logoutUrl?: string;
171
+ authCheckUrl?: string;
172
+ authCheckMethod?: string;
173
+ authCheckUserPath?: string;
174
+ };
175
+ headerLinks?: Array<{
176
+ label: string;
177
+ url: string;
178
+ icon?: string;
179
+ }>;
180
+ enableLlmsTxt?: boolean;
181
+ hasFeed?: boolean;
182
+ lastModified?: string;
183
+ baseUrl: string;
184
+ docsPath: string;
185
+ apiPath: string;
186
+ changelogPath: string;
187
+ docsUrl: string;
188
+ apiUrl: string;
189
+ changelogUrl: string;
190
+ editPageUrl?: string;
191
+ openGraph?: DoculaOpenGraph;
122
192
  };
123
-
124
- type GithubData = {
125
- releases: Record<string, unknown>;
126
- contributors: Record<string, unknown>;
193
+ type DoculaTemplates = {
194
+ home: string;
195
+ docPage?: string;
196
+ api?: string;
197
+ changelog?: string;
198
+ changelogEntry?: string;
199
+ };
200
+ type DoculaSection = {
201
+ name: string;
202
+ order?: number;
203
+ path: string;
204
+ children?: DoculaSection[];
205
+ };
206
+ type DoculaDocument = {
207
+ title: string;
208
+ navTitle: string;
209
+ description: string;
210
+ order?: number;
211
+ section?: string;
212
+ keywords: string[];
213
+ content: string;
214
+ markdown: string;
215
+ generatedHtml: string;
216
+ documentPath: string;
217
+ urlPath: string;
218
+ isRoot: boolean;
219
+ lastModified: string;
220
+ ogTitle?: string;
221
+ ogDescription?: string;
222
+ ogImage?: string;
127
223
  };
128
224
 
129
225
  type DoculaCookieAuth = {
@@ -138,11 +234,25 @@ type DoculaHeaderLink = {
138
234
  url: string;
139
235
  icon?: string;
140
236
  };
237
+ type DoculaOpenGraph = {
238
+ title?: string;
239
+ description?: string;
240
+ image?: string;
241
+ url?: string;
242
+ type?: string;
243
+ siteName?: string;
244
+ twitterCard?: string;
245
+ };
141
246
  type DoculaCacheOptions = {
142
247
  github: {
143
248
  ttl: number;
144
249
  };
145
250
  };
251
+ type DoculaAIOptions = {
252
+ provider: string;
253
+ model?: string;
254
+ apiKey: string;
255
+ };
146
256
  declare class DoculaOptions {
147
257
  /**
148
258
  * Name of the built-in template to use (e.g., "modern", "classic")
@@ -214,6 +324,16 @@ declare class DoculaOptions {
214
324
  * site directory's .gitignore file if not already present.
215
325
  */
216
326
  autoUpdateIgnores: boolean;
327
+ /**
328
+ * When true, automatically copies the project root README.md into the site
329
+ * directory if one does not already exist. The package.json name field is
330
+ * used to prepend a title heading when the README lacks one.
331
+ */
332
+ autoReadme: boolean;
333
+ /**
334
+ * When true, suppresses all non-error console output during the build.
335
+ */
336
+ quiet: boolean;
217
337
  /**
218
338
  * Base URL path prefix for all generated paths (e.g., "/docs").
219
339
  * When set, all asset and navigation URLs are prefixed with this path.
@@ -232,6 +352,19 @@ declare class DoculaOptions {
232
352
  * Output subdirectory and URL segment for changelog pages.
233
353
  */
234
354
  changelogPath: string;
355
+ /**
356
+ * Base URL for "Edit this page" links on documentation pages.
357
+ * When set, an edit link is shown at the bottom of each doc page.
358
+ * The document's relative path is appended to this URL.
359
+ * Example: "https://github.com/owner/repo/edit/main/site/docs"
360
+ */
361
+ editPageUrl?: string;
362
+ /**
363
+ * OpenGraph meta tags for social sharing. When set, og: and twitter:
364
+ * meta tags are rendered in the page head. Fields fall back to
365
+ * siteTitle / siteDescription / siteUrl when omitted.
366
+ */
367
+ openGraph?: DoculaOpenGraph;
235
368
  /**
236
369
  * Cookie-based authentication. When set, shows a Login/Logout button
237
370
  * in the header based on whether a JWT cookie is present.
@@ -243,9 +376,11 @@ declare class DoculaOptions {
243
376
  */
244
377
  headerLinks?: DoculaHeaderLink[];
245
378
  /**
246
- * File extensions to copy as assets from docs/ and changelog/ directories.
247
- * Override in docula.config to customize.
379
+ * AI-powered metadata enrichment configuration. When set, uses AI to fill
380
+ * missing OpenGraph and HTML meta tag fields during the build.
381
+ * Requires provider name and API key. Omit to disable AI enrichment.
248
382
  */
383
+ ai?: DoculaAIOptions;
249
384
  /**
250
385
  * Cache settings. Controls caching of external data (e.g., GitHub API responses)
251
386
  * in the .cache directory within the site path.
@@ -260,103 +395,21 @@ declare class DoculaOptions {
260
395
  parseOptions(options: Record<string, any>): void;
261
396
  }
262
397
 
263
- type DoculaChangelogEntry = {
264
- title: string;
265
- date: string;
266
- formattedDate: string;
267
- tag?: string;
268
- tagClass?: string;
269
- slug: string;
270
- content: string;
271
- generatedHtml: string;
272
- preview: string;
273
- previewImage?: string;
274
- urlPath: string;
275
- lastModified: string;
276
- };
277
- type DoculaData = {
278
- siteUrl: string;
279
- siteTitle: string;
280
- siteDescription: string;
281
- sitePath: string;
282
- templatePath: string;
283
- output: string;
284
- githubPath?: string;
285
- github?: GithubData;
286
- templates?: DoculaTemplates;
287
- hasDocuments?: boolean;
288
- hasChangelog?: boolean;
289
- sections?: DoculaSection[];
290
- documents?: DoculaDocument[];
291
- sidebarItems?: DoculaSection[];
292
- announcement?: string;
293
- openApiUrl?: string;
294
- hasApi?: boolean;
295
- apiSpec?: ApiSpecData;
296
- changelogEntries?: DoculaChangelogEntry[];
297
- hasReadme?: boolean;
298
- themeMode?: string;
299
- cookieAuth?: {
300
- loginUrl: string;
301
- logoutUrl?: string;
302
- authCheckUrl?: string;
303
- authCheckMethod?: string;
304
- authCheckUserPath?: string;
305
- };
306
- headerLinks?: Array<{
307
- label: string;
308
- url: string;
309
- icon?: string;
310
- }>;
311
- enableLlmsTxt?: boolean;
312
- hasFeed?: boolean;
313
- lastModified?: string;
314
- baseUrl: string;
315
- docsPath: string;
316
- apiPath: string;
317
- changelogPath: string;
318
- docsUrl: string;
319
- apiUrl: string;
320
- changelogUrl: string;
321
- };
322
- type DoculaTemplates = {
323
- home: string;
324
- docPage?: string;
325
- api?: string;
326
- changelog?: string;
327
- changelogEntry?: string;
328
- };
329
- type DoculaSection = {
330
- name: string;
331
- order?: number;
332
- path: string;
333
- children?: DoculaSection[];
334
- };
335
- type DoculaDocument = {
336
- title: string;
337
- navTitle: string;
338
- description: string;
339
- order?: number;
340
- section?: string;
341
- keywords: string[];
342
- content: string;
343
- markdown: string;
344
- generatedHtml: string;
345
- documentPath: string;
346
- urlPath: string;
347
- isRoot: boolean;
348
- lastModified: string;
349
- };
398
+ type DoculaBuilderOptions = {
399
+ console?: DoculaConsole;
400
+ } & DoculaOptions;
350
401
  declare class DoculaBuilder {
351
402
  private readonly _options;
352
403
  private readonly _ecto;
353
404
  private readonly _console;
354
405
  private readonly _hash;
355
406
  onReleaseChangelog?: (entries: DoculaChangelogEntry[], console: DoculaConsole) => Promise<DoculaChangelogEntry[]> | DoculaChangelogEntry[];
356
- constructor(options?: DoculaOptions, engineOptions?: any);
407
+ get console(): DoculaConsole;
408
+ constructor(options?: DoculaBuilderOptions, engineOptions?: any);
357
409
  get options(): DoculaOptions;
358
410
  build(): Promise<void>;
359
411
  validateOptions(options: DoculaOptions): void;
412
+ autoReadme(): Promise<void>;
360
413
  getGithubData(githubPath: string): Promise<GithubData>;
361
414
  getTemplates(templatePath: string, hasDocuments: boolean, hasChangelog?: boolean): Promise<DoculaTemplates>;
362
415
  getTemplateFile(path: string, name: string): Promise<string | undefined>;
@@ -365,22 +418,16 @@ declare class DoculaBuilder {
365
418
  buildFeedPage(data: DoculaData): Promise<void>;
366
419
  buildChangelogFeedJson(data: DoculaData): Promise<void>;
367
420
  buildChangelogLatestFeedJson(data: DoculaData): Promise<void>;
368
- private writeChangelogFeedJson;
369
421
  buildLlmsFiles(data: DoculaData): Promise<void>;
370
- private generateLlmsIndexContent;
371
- private generateLlmsFullContent;
372
- private buildUrlPath;
373
- private buildAbsoluteSiteUrl;
374
- private normalizePathForUrl;
375
- private escapeXml;
376
- private summarizeMarkdown;
377
- private isRemoteUrl;
378
- private resolveOpenApiSpecUrl;
379
- private resolveLocalOpenApiPath;
380
- private getSafeSiteOverrideFileContent;
381
- private getSafeLocalOpenApiSpec;
382
- private isPathWithinBasePath;
383
- private toPosixPath;
422
+ resolveOpenGraphData(data: DoculaData, pageUrl: string, pageData?: Partial<DoculaDocument> & {
423
+ previewImage?: string;
424
+ preview?: string;
425
+ }): Record<string, string | undefined>;
426
+ resolveJsonLd(pageType: "home" | "docs" | "api" | "changelog" | "changelog-entry", data: DoculaData, pageUrl: string, pageData?: Partial<DoculaDocument> & {
427
+ date?: string;
428
+ preview?: string;
429
+ previewImage?: string;
430
+ }): string;
384
431
  buildIndexPage(data: DoculaData): Promise<void>;
385
432
  buildDocsHomePage(data: DoculaData): Promise<void>;
386
433
  buildReadmeSection(data: DoculaData): Promise<string>;
@@ -402,36 +449,6 @@ declare class DoculaBuilder {
402
449
  getSections(sitePath: string, doculaOptions: DoculaOptions): DoculaSection[];
403
450
  mergeSectionWithOptions(section: DoculaSection, options: DoculaOptions): DoculaSection;
404
451
  parseDocumentData(documentPath: string): DoculaDocument;
405
- private hasTableOfContents;
406
- private directoryContainsMarkdown;
407
- private mergeTemplateOverrides;
408
- private ensureCacheInGitignore;
409
- private getChangedOverrides;
410
- private hashFile;
411
- private listFilesRecursive;
412
- private copyDirectory;
413
- private copyPublicFolder;
414
- private copyPublicDirectory;
415
- private copyDocumentSiblingAssets;
416
- private listContentAssets;
417
- private loadBuildManifest;
418
- private saveBuildManifest;
419
- private hashOptions;
420
- private hashTemplateDirectory;
421
- private loadCachedDocuments;
422
- private saveCachedDocuments;
423
- private loadCachedChangelog;
424
- private saveCachedChangelog;
425
- private hashSourceFiles;
426
- private recordsEqual;
427
- private hasAssetsChanged;
428
- /**
429
- * Hashes the source file, records it in currentAssets, and returns
430
- * whether the copy can be skipped (unchanged from previous build).
431
- */
432
- private hashAssetAndCheckSkip;
433
- private copyDirectoryWithHashing;
434
- private copyContentAssets;
435
452
  }
436
453
 
437
454
  declare class Docula {
@@ -440,6 +457,7 @@ declare class Docula {
440
457
  private _configFileModule;
441
458
  private _server;
442
459
  private _watcher;
460
+ get console(): DoculaConsole;
443
461
  /**
444
462
  * Initialize the Docula class
445
463
  * @param {DoculaOptions} options
@@ -503,6 +521,26 @@ declare class Docula {
503
521
  * @returns {void}
504
522
  */
505
523
  generateInit(sitePath: string, typescript?: boolean): void;
524
+ /**
525
+ * Copy the template's variables.css to the site directory.
526
+ * If the file already exists and overwrite is false, prints an error.
527
+ * @param {string} sitePath
528
+ * @param {string} templatePath
529
+ * @param {string} templateName
530
+ * @param {boolean} overwrite
531
+ * @returns {void}
532
+ */
533
+ downloadVariables(sitePath: string, templatePath: string, templateName: string, overwrite?: boolean): void;
534
+ /**
535
+ * Copy the full template directory to {sitePath}/templates/{outputName}/.
536
+ * If the directory already exists and overwrite is false, prints an error.
537
+ * @param {string} sitePath
538
+ * @param {string} templatePath
539
+ * @param {string} templateName
540
+ * @param {boolean} overwrite
541
+ * @returns {void}
542
+ */
543
+ downloadTemplate(sitePath: string, templatePath: string, templateName: string, overwrite?: boolean): void;
506
544
  /**
507
545
  * Get the version of the package
508
546
  * @returns {string}
@@ -530,4 +568,4 @@ declare class Docula {
530
568
  serve(options: DoculaOptions): Promise<http.Server>;
531
569
  }
532
570
 
533
- export { type DoculaCacheOptions, type DoculaChangelogEntry, DoculaConsole, type DoculaCookieAuth, type DoculaHeaderLink, DoculaOptions, Docula as default };
571
+ export { type DoculaAIOptions, type DoculaCacheOptions, type DoculaChangelogEntry, DoculaConsole, type DoculaCookieAuth, type DoculaHeaderLink, DoculaOptions, Docula as default };