@pterodoc/core 0.2.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.
Files changed (130) hide show
  1. package/LICENCE.md +10 -0
  2. package/README.md +12 -0
  3. package/lib/chunks/capture-BhdvHwrN.js +428 -0
  4. package/lib/chunks/capture-BhdvHwrN.js.map +1 -0
  5. package/lib/chunks/issues-DBsPh6ek.js +55 -0
  6. package/lib/chunks/issues-DBsPh6ek.js.map +1 -0
  7. package/lib/chunks/mime-2SUyOolJ.js +62 -0
  8. package/lib/chunks/mime-2SUyOolJ.js.map +1 -0
  9. package/lib/chunks/paths-Bh6UsRI9.js +177 -0
  10. package/lib/chunks/paths-Bh6UsRI9.js.map +1 -0
  11. package/lib/config/load.d.ts +123 -0
  12. package/lib/config/load.d.ts.map +1 -0
  13. package/lib/config/types.d.ts +136 -0
  14. package/lib/config/types.d.ts.map +1 -0
  15. package/lib/errors.d.ts +53 -0
  16. package/lib/errors.d.ts.map +1 -0
  17. package/lib/index.d.ts +23 -0
  18. package/lib/index.d.ts.map +1 -0
  19. package/lib/index.js +807 -0
  20. package/lib/index.js.map +1 -0
  21. package/lib/model/capture.d.ts +37 -0
  22. package/lib/model/capture.d.ts.map +1 -0
  23. package/lib/model/index.d.ts +13 -0
  24. package/lib/model/index.d.ts.map +1 -0
  25. package/lib/model/index.js +7 -0
  26. package/lib/model/index.js.map +1 -0
  27. package/lib/model/reader.d.ts +25 -0
  28. package/lib/model/reader.d.ts.map +1 -0
  29. package/lib/model/tree.d.ts +81 -0
  30. package/lib/model/tree.d.ts.map +1 -0
  31. package/lib/model/types.d.ts +166 -0
  32. package/lib/model/types.d.ts.map +1 -0
  33. package/lib/render/admonitions.d.ts +26 -0
  34. package/lib/render/admonitions.d.ts.map +1 -0
  35. package/lib/render/blocks.d.ts +39 -0
  36. package/lib/render/blocks.d.ts.map +1 -0
  37. package/lib/render/code.d.ts +37 -0
  38. package/lib/render/code.d.ts.map +1 -0
  39. package/lib/render/components.d.ts +49 -0
  40. package/lib/render/components.d.ts.map +1 -0
  41. package/lib/render/excerpt.d.ts +9 -0
  42. package/lib/render/excerpt.d.ts.map +1 -0
  43. package/lib/render/images.d.ts +58 -0
  44. package/lib/render/images.d.ts.map +1 -0
  45. package/lib/render/index.d.ts +80 -0
  46. package/lib/render/index.d.ts.map +1 -0
  47. package/lib/render/index.js +1336 -0
  48. package/lib/render/index.js.map +1 -0
  49. package/lib/render/inline.d.ts +25 -0
  50. package/lib/render/inline.d.ts.map +1 -0
  51. package/lib/render/links.d.ts +45 -0
  52. package/lib/render/links.d.ts.map +1 -0
  53. package/lib/render/mdx.d.ts +37 -0
  54. package/lib/render/mdx.d.ts.map +1 -0
  55. package/lib/render/page.d.ts +85 -0
  56. package/lib/render/page.d.ts.map +1 -0
  57. package/lib/render/parse.d.ts +27 -0
  58. package/lib/render/parse.d.ts.map +1 -0
  59. package/lib/render/references.d.ts +20 -0
  60. package/lib/render/references.d.ts.map +1 -0
  61. package/lib/render/renderers.d.ts +57 -0
  62. package/lib/render/renderers.d.ts.map +1 -0
  63. package/lib/render/slug.d.ts +34 -0
  64. package/lib/render/slug.d.ts.map +1 -0
  65. package/lib/render/theme.d.ts +62 -0
  66. package/lib/render/theme.d.ts.map +1 -0
  67. package/lib/sync/artifacts.d.ts +46 -0
  68. package/lib/sync/artifacts.d.ts.map +1 -0
  69. package/lib/sync/plan.d.ts +59 -0
  70. package/lib/sync/plan.d.ts.map +1 -0
  71. package/lib/sync/run.d.ts +39 -0
  72. package/lib/sync/run.d.ts.map +1 -0
  73. package/lib/target/index.d.ts +8 -0
  74. package/lib/target/index.d.ts.map +1 -0
  75. package/lib/target/index.js +2 -0
  76. package/lib/target/index.js.map +1 -0
  77. package/lib/target/target.d.ts +152 -0
  78. package/lib/target/target.d.ts.map +1 -0
  79. package/lib/util/hash.d.ts +10 -0
  80. package/lib/util/hash.d.ts.map +1 -0
  81. package/lib/util/index.d.ts +14 -0
  82. package/lib/util/index.d.ts.map +1 -0
  83. package/lib/util/index.js +7 -0
  84. package/lib/util/index.js.map +1 -0
  85. package/lib/util/issues.d.ts +52 -0
  86. package/lib/util/issues.d.ts.map +1 -0
  87. package/lib/util/mime.d.ts +16 -0
  88. package/lib/util/mime.d.ts.map +1 -0
  89. package/lib/util/paths.d.ts +42 -0
  90. package/lib/util/paths.d.ts.map +1 -0
  91. package/lib/version.d.ts +6 -0
  92. package/lib/version.d.ts.map +1 -0
  93. package/package.json +43 -0
  94. package/src/config/load.ts +387 -0
  95. package/src/config/types.ts +137 -0
  96. package/src/errors.ts +77 -0
  97. package/src/globals.d.ts +10 -0
  98. package/src/index.ts +31 -0
  99. package/src/model/capture.ts +92 -0
  100. package/src/model/index.ts +25 -0
  101. package/src/model/reader.ts +37 -0
  102. package/src/model/tree.ts +416 -0
  103. package/src/model/types.ts +167 -0
  104. package/src/render/admonitions.ts +74 -0
  105. package/src/render/blocks.ts +79 -0
  106. package/src/render/code.ts +112 -0
  107. package/src/render/components.ts +230 -0
  108. package/src/render/excerpt.ts +16 -0
  109. package/src/render/images.ts +113 -0
  110. package/src/render/index.ts +129 -0
  111. package/src/render/inline.ts +62 -0
  112. package/src/render/links.ts +94 -0
  113. package/src/render/mdx.ts +178 -0
  114. package/src/render/page.ts +289 -0
  115. package/src/render/parse.ts +65 -0
  116. package/src/render/references.ts +69 -0
  117. package/src/render/renderers.ts +346 -0
  118. package/src/render/slug.ts +63 -0
  119. package/src/render/theme.ts +92 -0
  120. package/src/sync/artifacts.ts +70 -0
  121. package/src/sync/plan.ts +69 -0
  122. package/src/sync/run.ts +641 -0
  123. package/src/target/index.ts +18 -0
  124. package/src/target/target.ts +146 -0
  125. package/src/util/hash.ts +14 -0
  126. package/src/util/index.ts +23 -0
  127. package/src/util/issues.ts +86 -0
  128. package/src/util/mime.ts +47 -0
  129. package/src/util/paths.ts +101 -0
  130. package/src/version.ts +31 -0
@@ -0,0 +1,177 @@
1
+ import 'node:fs';
2
+ import path from 'node:path';
3
+
4
+ /**
5
+ * The error types the CLI knows how to present, and the exit codes they map to.
6
+ *
7
+ * Codes 0, 1 and 2 keep the meaning the DocStack sync script established, so a
8
+ * workflow that already branches on them does not change behaviour.
9
+ */
10
+ const EXIT = {
11
+ /** Everything asked for was done. */
12
+ ok: 0,
13
+ /** The configuration or the command line was wrong; printed without a stack. */
14
+ config: 1,
15
+ /** The target refused a request. */
16
+ target: 2,
17
+ /** `--strict` was given and an issue reached the configured severity. */
18
+ strict: 3,
19
+ /** Something we did not anticipate; printed with a stack. */
20
+ internal: 4,
21
+ };
22
+ /** Base class for every error this tool raises deliberately. */
23
+ class PterodocError extends Error {
24
+ /** Exit code the CLI should use. */
25
+ exitCode;
26
+ constructor(message, exitCode = EXIT.internal) {
27
+ super(message);
28
+ this.name = new.target.name;
29
+ this.exitCode = exitCode;
30
+ }
31
+ }
32
+ /** A user-fixable problem with the configuration, the flags or the environment. */
33
+ class ConfigError extends PterodocError {
34
+ constructor(message) {
35
+ super(message, EXIT.config);
36
+ }
37
+ }
38
+ /** The target rejected a request, or could not be reached. */
39
+ class TargetError extends PterodocError {
40
+ /** HTTP status, or 0 when the request never completed. */
41
+ status;
42
+ /** Machine-readable code the target supplied, when it supplied one. */
43
+ code;
44
+ /** HTTP method of the failed request. */
45
+ method;
46
+ /** URL of the failed request. */
47
+ url;
48
+ /** First part of the response body, for diagnosis. */
49
+ bodySnippet;
50
+ constructor(message, details) {
51
+ super(message, EXIT.target);
52
+ this.status = details.status;
53
+ this.code = details.code;
54
+ this.method = details.method;
55
+ this.url = details.url;
56
+ this.bodySnippet = details.bodySnippet ?? '';
57
+ }
58
+ }
59
+ /** Content that this tool cannot represent in the target, when configured to fail on it. */
60
+ class UnsupportedContentError extends PterodocError {
61
+ constructor(message) {
62
+ super(message, EXIT.strict);
63
+ }
64
+ }
65
+
66
+ /** The tool's own version, stamped into the build. */
67
+ /**
68
+ * Read the version.
69
+ *
70
+ * The build replaces the token, so a built artefact never touches the disk and
71
+ * does not care how deeply it is nested. Running from source — tsx, the test
72
+ * suite, an editor — there is no token, and the manifest sits exactly one
73
+ * directory above this file.
74
+ *
75
+ * `typeof` on an undeclared identifier is the one expression that does not
76
+ * throw, so the ambient declaration costs nothing at runtime.
77
+ */
78
+ function readVersion() {
79
+ return "0.2.0";
80
+ }
81
+ /** Semantic version of this package. */
82
+ const VERSION = readVersion();
83
+ /** The User-Agent every outbound request identifies itself with. */
84
+ const USER_AGENT = `pterodoc/${VERSION} (+https://github.com/onyx-ac/pterodoc)`;
85
+
86
+ /**
87
+ * Path helpers shared by the source reader and the targets.
88
+ *
89
+ * Everything here is POSIX-shaped: a documentation tree is addressed by URL
90
+ * paths, not by the host's separators.
91
+ */
92
+ /** Prefix Docusaurus uses for paths relative to the site directory. */
93
+ const SITE_ALIAS = '@site/';
94
+ /**
95
+ * Resolve a Docusaurus `@site/...` path to an absolute one.
96
+ *
97
+ * @param aliased The path as Docusaurus records it, e.g. `@site/docs/intro.md`.
98
+ * @param siteDir Absolute path of the Docusaurus site directory.
99
+ */
100
+ function resolveAliasedPath(aliased, siteDir) {
101
+ if (!aliased.startsWith(SITE_ALIAS)) {
102
+ throw new ConfigError(`Expected a "@site/"-relative path from Docusaurus but got "${aliased}". This usually means an unsupported Docusaurus version.`);
103
+ }
104
+ return path.resolve(siteDir, aliased.slice(SITE_ALIAS.length));
105
+ }
106
+ /** Turn a host path into the POSIX form used for ids and messages. */
107
+ function toPosix(value) {
108
+ return value.split(path.sep).join('/');
109
+ }
110
+ /** Split a URL-ish path into its non-empty segments. */
111
+ function segments(value) {
112
+ return value.split('/').filter(Boolean);
113
+ }
114
+ /**
115
+ * Split a configured path into slug segments, rejecting anything WordPress
116
+ * would not accept as a page slug.
117
+ *
118
+ * @param value A path such as `/products/docstack`.
119
+ * @param label The setting's name, used in the error message.
120
+ */
121
+ function toSlugSegments(value, label) {
122
+ const parts = segments(String(value ?? '').trim());
123
+ for (const part of parts) {
124
+ if (!/^[a-z0-9]+(?:[-_][a-z0-9]+)*$/.test(part)) {
125
+ throw new ConfigError(`${label} segment "${part}" is not a slug. Use lowercase letters, digits, hyphens and underscores.`);
126
+ }
127
+ }
128
+ return parts;
129
+ }
130
+ /**
131
+ * Make a slug out of arbitrary text, for path segments we derive ourselves
132
+ * (a version name, for instance) rather than receive from Docusaurus.
133
+ */
134
+ function slugify(value) {
135
+ return String(value)
136
+ .normalize('NFKD')
137
+ .replace(/[\u0300-\u036f]/g, '')
138
+ .toLowerCase()
139
+ .replace(/[^a-z0-9]+/g, '-')
140
+ .replace(/^-+|-+$/g, '') || 'untitled';
141
+ }
142
+ /** Title-case a slug, for a page that has no better label available. */
143
+ function titleCase(slug) {
144
+ return segments(slug.replace(/[-_]/g, ' ').replace(/\s+/g, ' '))
145
+ .join(' ')
146
+ .split(' ')
147
+ .filter(Boolean)
148
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
149
+ .join(' ');
150
+ }
151
+ /**
152
+ * The path a URL points at below a prefix.
153
+ *
154
+ * Returns undefined when `url` is not under `prefix`, which is how the link
155
+ * resolver decides whether a link belongs to the documentation at all.
156
+ */
157
+ function relativeToPrefix(url, prefix) {
158
+ const normalisedPrefix = `/${segments(prefix).join('/')}`;
159
+ const normalisedUrl = `/${segments(url).join('/')}`;
160
+ if (normalisedPrefix === '/')
161
+ return segments(normalisedUrl).join('/');
162
+ if (normalisedUrl === normalisedPrefix)
163
+ return '';
164
+ if (!normalisedUrl.startsWith(`${normalisedPrefix}/`))
165
+ return undefined;
166
+ return normalisedUrl.slice(normalisedPrefix.length + 1);
167
+ }
168
+ /** Join path segments into an absolute URL path with a trailing slash. */
169
+ function joinPath(parts, trailingSlash = true) {
170
+ const joined = parts.flatMap((part) => segments(part)).join('/');
171
+ if (joined === '')
172
+ return '/';
173
+ return trailingSlash ? `/${joined}/` : `/${joined}`;
174
+ }
175
+
176
+ export { ConfigError as C, EXIT as E, PterodocError as P, TargetError as T, USER_AGENT as U, VERSION as V, UnsupportedContentError as a, resolveAliasedPath as b, slugify as c, toPosix as d, toSlugSegments as e, joinPath as j, relativeToPrefix as r, segments as s, titleCase as t };
177
+ //# sourceMappingURL=paths-Bh6UsRI9.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths-Bh6UsRI9.js","sources":["../../src/errors.ts","../../src/version.ts","../../src/util/paths.ts"],"sourcesContent":[null,null,null],"names":[],"mappings":";;;AAAA;;;;;AAKG;AAEI,MAAM,IAAI,GAAG;;AAElB,IAAA,EAAE,EAAE,CAAC;;AAEL,IAAA,MAAM,EAAE,CAAC;;AAET,IAAA,MAAM,EAAE,CAAC;;AAET,IAAA,MAAM,EAAE,CAAC;;AAET,IAAA,QAAQ,EAAE,CAAC;;AAGb;AACM,MAAO,aAAc,SAAQ,KAAK,CAAA;;AAE7B,IAAA,QAAQ;AAEjB,IAAA,WAAA,CAAY,OAAe,EAAE,QAAA,GAAmB,IAAI,CAAC,QAAQ,EAAA;QAC3D,KAAK,CAAC,OAAO,CAAC;QACd,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI;AAC3B,QAAA,IAAI,CAAC,QAAQ,GAAG,QAAQ;IAC1B;AACD;AAED;AACM,MAAO,WAAY,SAAQ,aAAa,CAAA;AAC5C,IAAA,WAAA,CAAY,OAAe,EAAA;AACzB,QAAA,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC;IAC7B;AACD;AAED;AACM,MAAO,WAAY,SAAQ,aAAa,CAAA;;AAEnC,IAAA,MAAM;;AAEN,IAAA,IAAI;;AAEJ,IAAA,MAAM;;AAEN,IAAA,GAAG;;AAEH,IAAA,WAAW;IAEpB,WAAA,CACE,OAAe,EACf,OAMC,EAAA;AAED,QAAA,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC;AAC3B,QAAA,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM;AAC5B,QAAA,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI;AACxB,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AI,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;IACnD,IAAI,gBAAgB,KAAK,GAAG;QAAE,OAAO,QAAQ,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;IACtE,IAAI,aAAa,KAAK,gBAAgB;AAAE,QAAA,OAAO,EAAE;IACjD,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAA,EAAG,gBAAgB,GAAG,CAAC;AAAE,QAAA,OAAO,SAAS;IACvE,OAAO,aAAa,CAAC,KAAK,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC;AACzD;AAEA;SACgB,QAAQ,CAAC,KAAe,EAAE,aAAa,GAAG,IAAI,EAAA;IAC5D,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;IAChE,IAAI,MAAM,KAAK,EAAE;AAAE,QAAA,OAAO,GAAG;AAC7B,IAAA,OAAO,aAAa,GAAG,CAAA,CAAA,EAAI,MAAM,CAAA,CAAA,CAAG,GAAG,CAAA,CAAA,EAAI,MAAM,EAAE;AACrD;;"}
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Discovering, merging and validating configuration.
3
+ *
4
+ * Precedence is flags, then the environment, then the config file, then the
5
+ * defaults. Nothing here touches `process.env` or the disk except through the
6
+ * dependencies it is given, so it is testable without either.
7
+ */
8
+ import { type PageLayout } from '../render/page';
9
+ import { type Strings } from '../render/theme';
10
+ import type { Severity } from '../util/issues';
11
+ import type { PterodocConfig } from './types';
12
+ /** File names tried, in order, when no config is named. */
13
+ export declare const CONFIG_NAMES: string[];
14
+ /** Flags the CLI can supply, already parsed. */
15
+ export interface ConfigFlags {
16
+ siteDir?: string | undefined;
17
+ config?: string | undefined;
18
+ docusaurusConfig?: string | undefined;
19
+ model?: string | undefined;
20
+ instance?: string[] | undefined;
21
+ locale?: string[] | undefined;
22
+ allLocales?: boolean | undefined;
23
+ docsVersion?: string[] | undefined;
24
+ allVersions?: boolean | undefined;
25
+ root?: string | undefined;
26
+ base?: string | undefined;
27
+ status?: string | undefined;
28
+ only?: string | undefined;
29
+ out?: string | undefined;
30
+ dryRun?: boolean | undefined;
31
+ prune?: boolean | undefined;
32
+ offline?: boolean | undefined;
33
+ noMedia?: boolean | undefined;
34
+ strict?: boolean | undefined;
35
+ envFile?: string | undefined;
36
+ }
37
+ /** Everything the run needs, with nothing left to decide. */
38
+ export interface ResolvedConfig {
39
+ siteDir: string;
40
+ configFile: string | undefined;
41
+ docusaurusConfig: string | undefined;
42
+ modelFile: string | undefined;
43
+ instances: string[] | 'all';
44
+ sidebars: string[] | 'all';
45
+ versions: string[] | 'all' | 'last';
46
+ locales: string[] | 'all' | 'default';
47
+ includeDrafts: boolean;
48
+ includeUnlisted: boolean;
49
+ includeOrphans: boolean;
50
+ targetType: 'wordpress';
51
+ targetUrl: string;
52
+ user: string;
53
+ appPassword: string;
54
+ rootSegments: string[];
55
+ baseSegments: string[];
56
+ docsTitle: string;
57
+ status: 'publish' | 'draft' | 'private';
58
+ template: string;
59
+ lang: string;
60
+ metaDescriptionKey: string;
61
+ methodOverride: boolean;
62
+ retry: {
63
+ attempts: number;
64
+ baseDelayMs: number;
65
+ maxDelayMs: number;
66
+ };
67
+ layout: PageLayout;
68
+ classPrefix: string;
69
+ /** Which block vocabulary the renderer emits. */
70
+ blocks: 'core' | 'plugin';
71
+ dedupeTitle: boolean;
72
+ unpublishedLinks: 'site' | 'drop';
73
+ siteUrl: string;
74
+ excerptLength: number;
75
+ strings: Strings;
76
+ localeStrings: Record<string, Partial<Strings>>;
77
+ mdxOnUnknown: 'report' | 'placeholder' | 'error';
78
+ uploadMedia: boolean;
79
+ uploadRemoteMedia: boolean;
80
+ mediaOnMissing: Severity | 'ignore';
81
+ mediaSlugPrefix: string;
82
+ outDir: string;
83
+ writePages: boolean;
84
+ only: string;
85
+ dryRun: boolean;
86
+ prune: boolean;
87
+ offline: boolean;
88
+ strict: boolean;
89
+ strictAt: Severity;
90
+ /** Told to the user before anything happens. */
91
+ notices: string[];
92
+ }
93
+ /** Injected so configuration can be resolved without touching the disk. */
94
+ export interface ConfigDeps {
95
+ readFileSync?: (file: string) => string;
96
+ existsSync?: (file: string) => boolean;
97
+ cwd?: () => string;
98
+ }
99
+ /** Find a configuration file next to the site. */
100
+ export declare function discoverConfigFile(siteDir: string, deps: Required<Pick<ConfigDeps, 'existsSync'>>): string | undefined;
101
+ /** Load a configuration file. */
102
+ export declare function readConfigFile(file: string): Promise<PterodocConfig>;
103
+ /**
104
+ * Resolve everything into the shape the run reads.
105
+ *
106
+ * @param input Flags, the file's contents, and the environment.
107
+ */
108
+ export declare function resolveConfig(input: {
109
+ flags?: ConfigFlags;
110
+ file?: PterodocConfig;
111
+ fileDir?: string;
112
+ env?: NodeJS.ProcessEnv;
113
+ configFile?: string | undefined;
114
+ }): ResolvedConfig;
115
+ /**
116
+ * Discover, read and resolve the configuration.
117
+ *
118
+ * @param flags Parsed command line flags.
119
+ * @param env The environment to read.
120
+ * @param deps Injected filesystem access.
121
+ */
122
+ export declare function loadConfig(flags?: ConfigFlags, env?: NodeJS.ProcessEnv, deps?: ConfigDeps): Promise<ResolvedConfig>;
123
+ //# sourceMappingURL=load.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../src/config/load.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,OAAO,EAAkB,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAmB,KAAK,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,2DAA2D;AAC3D,eAAO,MAAM,YAAY,UAMxB,CAAC;AAEF,gDA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;;;;;;GAMG;AACH,wBAAsB,UAAU,CAC9B,KAAK,GAAE,WAAgB,EACvB,GAAG,GAAE,MAAM,CAAC,UAAwB,EACpC,IAAI,GAAE,UAAe,GACpB,OAAO,CAAC,cAAc,CAAC,CAwBzB"}
@@ -0,0 +1,136 @@
1
+ /**
2
+ * The configuration a site writes, and the resolved shape the tool reads.
3
+ *
4
+ * Credentials never appear here: the config names the environment variables
5
+ * that hold them, so a config file is safe to commit.
6
+ */
7
+ import type { Severity } from '../util/issues';
8
+ import type { PageLayout } from '../render/page';
9
+ import type { Strings } from '../render/theme';
10
+ /** Which documents to publish. */
11
+ export interface SiteConfig {
12
+ /** Docusaurus site directory. Relative paths resolve against the config file. */
13
+ dir?: string;
14
+ /** Explicit `docusaurus.config.*` path. */
15
+ config?: string;
16
+ /** Docs plugin instances to publish, or 'all'. */
17
+ instances?: string[] | 'all';
18
+ /** Sidebars to publish. A document no kept sidebar reaches is not published. */
19
+ sidebars?: string[] | 'all';
20
+ /** Versions to publish: 'last', 'all', or explicit names. */
21
+ versions?: string[] | 'all' | 'last';
22
+ /** Locales to publish: 'default', 'all', or explicit codes. */
23
+ locales?: string[] | 'all' | 'default';
24
+ /** Publish documents Docusaurus marks as drafts. */
25
+ includeDrafts?: boolean;
26
+ /** Publish documents Docusaurus marks as unlisted. */
27
+ includeUnlisted?: boolean;
28
+ /** Publish documents that belong to no sidebar. */
29
+ includeOrphans?: boolean;
30
+ }
31
+ /** Where to publish. */
32
+ export interface TargetConfig {
33
+ /** The only implementation today. */
34
+ type?: 'wordpress';
35
+ /** Site origin. Usually supplied by the environment instead. */
36
+ url?: string;
37
+ /** Which environment variables hold the credentials. */
38
+ auth?: {
39
+ userEnv?: string;
40
+ passwordEnv?: string;
41
+ };
42
+ /** Path the documentation tree hangs from. */
43
+ root?: string;
44
+ /** Segment below the root holding the docs; '' publishes under the root. */
45
+ base?: string;
46
+ /** Title of the documentation root when no document claims it. */
47
+ title?: string;
48
+ /** Status applied to every synced page. */
49
+ status?: 'publish' | 'draft' | 'private';
50
+ /** Page template slug. */
51
+ template?: string;
52
+ /** Polylang language code. */
53
+ lang?: string;
54
+ /** Map a rendered field onto a target metadata key. */
55
+ meta?: {
56
+ description?: string;
57
+ };
58
+ /** Send DELETE as POST with an override header. */
59
+ methodOverride?: boolean;
60
+ /** How hard to retry a busy site. */
61
+ retry?: {
62
+ attempts?: number;
63
+ baseDelayMs?: number;
64
+ maxDelayMs?: number;
65
+ };
66
+ }
67
+ /** How pages are rendered. */
68
+ export interface RenderConfig {
69
+ /** Prefix on every generated class name. */
70
+ classPrefix?: string;
71
+ /**
72
+ * Which block vocabulary to emit.
73
+ *
74
+ * `core` is the default and emits core blocks only. `plugin` additionally
75
+ * carries instructions the pterodoc WordPress plugin understands — chiefly
76
+ * highlighted line ranges, which core blocks cannot express at all — in block
77
+ * comments rather than in markup, so WordPress stores the same content either
78
+ * way. Set it once the plugin is installed; `pterodoc doctor` says whether it
79
+ * is.
80
+ */
81
+ blocks?: 'core' | 'plugin';
82
+ /** Drop a leading H1 that repeats the page title. */
83
+ dedupeTitle?: boolean;
84
+ /** Where links to unpublished documents point: the site, or nowhere. */
85
+ unpublishedLinks?: 'site' | 'drop';
86
+ /** Overrides the documentation site URL used by `unpublishedLinks: 'site'`. */
87
+ siteUrl?: string;
88
+ /** Longest excerpt, in characters. */
89
+ excerptLength?: number;
90
+ /** Human strings, overriding the defaults. */
91
+ strings?: Partial<Strings>;
92
+ /** Per-locale string overrides. */
93
+ localeStrings?: Record<string, Partial<Strings>>;
94
+ }
95
+ /** How MDX is handled. */
96
+ export interface MdxConfig {
97
+ /** What to do about JSX with no translation. */
98
+ onUnknown?: 'report' | 'placeholder' | 'error';
99
+ }
100
+ /** How assets are handled. */
101
+ export interface MediaConfig {
102
+ /** Upload local files to the target. */
103
+ upload?: boolean;
104
+ /** Also upload files that already point at another origin. */
105
+ uploadRemote?: boolean;
106
+ /** What to do when a referenced file is missing. */
107
+ onMissing?: Severity | 'ignore';
108
+ /** Prefix of the media slug that carries the content hash. */
109
+ slugPrefix?: string;
110
+ }
111
+ /** Where the run writes what it did. */
112
+ export interface OutputConfig {
113
+ /** Directory for rendered pages, the manifest and the plan. */
114
+ dir?: string;
115
+ /** Write each rendered page body as a file. */
116
+ pages?: boolean;
117
+ }
118
+ /** A pterodoc configuration file. */
119
+ export interface PterodocConfig {
120
+ site?: SiteConfig;
121
+ target?: TargetConfig;
122
+ layout?: Partial<PageLayout>;
123
+ render?: RenderConfig;
124
+ mdx?: MdxConfig;
125
+ media?: MediaConfig;
126
+ output?: OutputConfig;
127
+ /** With `--strict`, an issue at this severity or above fails the run. */
128
+ strict?: Severity;
129
+ }
130
+ /**
131
+ * Identity function that types a configuration file.
132
+ *
133
+ * @param config The configuration.
134
+ */
135
+ export declare function defineConfig(config: PterodocConfig): PterodocConfig;
136
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/config/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE/C,kCAAkC;AAClC,MAAM,WAAW,UAAU;IACzB,iFAAiF;IACjF,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;IAC7B,gFAAgF;IAChF,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;IAC5B,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,KAAK,GAAG,MAAM,CAAC;IACrC,+DAA+D;IAC/D,OAAO,CAAC,EAAE,M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AAM,CAAC,EAAE,YAAY,CAAC;IACtB,yEAAyE;IACzE,MAAM,CAAC,EAAE,QAAQ,CAAC;CACnB;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CAEnE"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * The error types the CLI knows how to present, and the exit codes they map to.
3
+ *
4
+ * Codes 0, 1 and 2 keep the meaning the DocStack sync script established, so a
5
+ * workflow that already branches on them does not change behaviour.
6
+ */
7
+ export declare const EXIT: {
8
+ /** Everything asked for was done. */
9
+ readonly ok: 0;
10
+ /** The configuration or the command line was wrong; printed without a stack. */
11
+ readonly config: 1;
12
+ /** The target refused a request. */
13
+ readonly target: 2;
14
+ /** `--strict` was given and an issue reached the configured severity. */
15
+ readonly strict: 3;
16
+ /** Something we did not anticipate; printed with a stack. */
17
+ readonly internal: 4;
18
+ };
19
+ /** Base class for every error this tool raises deliberately. */
20
+ export declare class PterodocError extends Error {
21
+ /** Exit code the CLI should use. */
22
+ readonly exitCode: number;
23
+ constructor(message: string, exitCode?: number);
24
+ }
25
+ /** A user-fixable problem with the configuration, the flags or the environment. */
26
+ export declare class ConfigError extends PterodocError {
27
+ constructor(message: string);
28
+ }
29
+ /** The target rejected a request, or could not be reached. */
30
+ export declare class TargetError extends PterodocError {
31
+ /** HTTP status, or 0 when the request never completed. */
32
+ readonly status: number;
33
+ /** Machine-readable code the target supplied, when it supplied one. */
34
+ readonly code: string | undefined;
35
+ /** HTTP method of the failed request. */
36
+ readonly method: string;
37
+ /** URL of the failed request. */
38
+ readonly url: string;
39
+ /** First part of the response body, for diagnosis. */
40
+ readonly bodySnippet: string;
41
+ constructor(message: string, details: {
42
+ status: number;
43
+ code?: string | undefined;
44
+ method: string;
45
+ url: string;
46
+ bodySnippet?: string;
47
+ });
48
+ }
49
+ /** Content that this tool cannot represent in the target, when configured to fail on it. */
50
+ export declare class UnsupportedContentError extends PterodocError {
51
+ constructor(message: string);
52
+ }
53
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,IAAI;IACf,qCAAqC;;IAErC,gFAAgF;;IAEhF,oCAAoC;;IAEpC,yEAAyE;;IAEzE,6DAA6D;;CAErD,CAAC;AAEX,gEAAgE;AAChE,qBAAa,aAAc,SAAQ,KAAK;IACtC,oCAAoC;IACpC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;gBAEd,OAAO,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAsB;CAK9D;AAED,mFAAmF;AACnF,qBAAa,WAAY,SAAQ,aAAa;gBAChC,OAAO,EAAE,MAAM;CAG5B;AAED,8DAA8D;AAC9D,qBAAa,WAAY,SAAQ,aAAa;IAC5C,0DAA0D;IAC1D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,uEAAuE;IACvE,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,yCAAyC;IACzC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,iCAAiC;IACjC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,sDAAsD;IACtD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;gBAG3B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;QACP,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC1B,MAAM,EAAE,MAAM,CAAC;QACf,GAAG,EAAE,MAAM,CAAC;QACZ,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB;CASJ;AAED,4FAA4F;AAC5F,qBAAa,uBAAwB,SAAQ,aAAa;gBAC5C,OAAO,EAAE,MAAM;CAG5B"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,23 @@
1
+ /**
2
+ * The parts of pterodoc that know neither where a model came from nor where it
3
+ * is going: rendering, the site model, the target contract and the reconciler.
4
+ *
5
+ * Most consumers want the `pterodoc` package instead; this is what the source
6
+ * and target packages build on.
7
+ */
8
+ export { EXIT, PterodocError, ConfigError, TargetError, UnsupportedContentError } from './errors';
9
+ export { VERSION, USER_AGENT } from './version';
10
+ export { defineConfig } from './config/types';
11
+ export type { PterodocConfig, SiteConfig, TargetConfig, RenderConfig, MdxConfig, MediaConfig, OutputConfig, } from './config/types';
12
+ export { loadConfig, resolveConfig, discoverConfigFile, CONFIG_NAMES } from './config/load';
13
+ export type { ResolvedConfig, ConfigFlags } from './config/load';
14
+ export { runSync } from './sync/run';
15
+ export type { RunResult, RunSyncDeps } from './sync/run';
16
+ export type { Plan, Action } from './sync/plan';
17
+ export * from './model/index';
18
+ export * from './target/index';
19
+ export { renderDoc, createTheme, composePage, DEFAULT_LAYOUT } from './render/index';
20
+ export type { RenderedDoc, Theme, Strings, PageLayout } from './render/index';
21
+ export { IssueCollector, formatIssue, compareSeverity } from './util/issues';
22
+ export type { Issue, Severity } from './util/issues';
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAClG,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,YAAY,EACV,cAAc,EACd,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,WAAW,EACX,YAAY,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC5F,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzD,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrF,YAAY,EAAE,WAAW,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC7E,YAAY,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC"}