@doxbrix/doxloop 0.1.4 → 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.
- package/CHANGELOG.md +1153 -0
- package/README.md +422 -226
- package/assets/doxbrix-preview.css +77 -15
- package/contracts/agent-events-v1.schema.json +1 -0
- package/contracts/coverage-v1.schema.json +59 -0
- package/contracts/drift-v1.schema.json +1 -0
- package/contracts/evaluation-v1.schema.json +62 -0
- package/contracts/quality-codes-v1.json +1 -0
- package/contracts/quality-report-v1.schema.json +1 -0
- package/contracts/validation-v1.schema.json +1 -0
- package/dist/agent-failure.d.ts +36 -0
- package/dist/agent-failure.js +98 -0
- package/dist/agent-isolation.d.ts +17 -0
- package/dist/agent-isolation.js +94 -0
- package/dist/agent-log.d.ts +197 -0
- package/dist/agent-log.js +1094 -0
- package/dist/agent-process.d.ts +63 -0
- package/dist/agent-process.js +128 -0
- package/dist/agent-reply.d.ts +47 -0
- package/dist/agent-reply.js +315 -0
- package/dist/agents.d.ts +40 -4
- package/dist/agents.js +115 -11
- package/dist/api-coverage.d.ts +11 -0
- package/dist/api-coverage.js +72 -0
- package/dist/application-probe.d.ts +28 -0
- package/dist/application-probe.js +93 -0
- package/dist/application-url.d.ts +14 -0
- package/dist/application-url.js +26 -0
- package/dist/args.js +15 -0
- package/dist/artifact-deploy.d.ts +9 -0
- package/dist/artifact-deploy.js +28 -8
- package/dist/assets.d.ts +72 -0
- package/dist/assets.js +382 -0
- package/dist/auth.d.ts +10 -0
- package/dist/auth.js +38 -9
- package/dist/author.d.ts +206 -4
- package/dist/author.js +1650 -52
- package/dist/authoring-batches.d.ts +190 -0
- package/dist/authoring-batches.js +489 -0
- package/dist/authoring-postpass.d.ts +79 -0
- package/dist/authoring-postpass.js +1289 -0
- package/dist/authoring-progress.d.ts +95 -0
- package/dist/authoring-progress.js +269 -0
- package/dist/autosync.d.ts +56 -0
- package/dist/autosync.js +442 -0
- package/dist/batch-artifacts.d.ts +81 -0
- package/dist/batch-artifacts.js +412 -0
- package/dist/batch-limits.d.ts +37 -0
- package/dist/batch-limits.js +80 -0
- package/dist/branding.d.ts +41 -0
- package/dist/branding.js +229 -0
- package/dist/bundle-upload.d.ts +26 -0
- package/dist/bundle-upload.js +99 -0
- package/dist/capture-auth.d.ts +95 -0
- package/dist/capture-auth.js +204 -0
- package/dist/capture.d.ts +48 -0
- package/dist/capture.js +20 -1
- package/dist/cli.js +839 -32
- package/dist/content-links.d.ts +10 -0
- package/dist/content-links.js +49 -0
- package/dist/contract-validation.d.ts +4 -0
- package/dist/contract-validation.js +25 -0
- package/dist/coverage-actions.d.ts +8 -0
- package/dist/coverage-actions.js +71 -0
- package/dist/coverage-resolutions.d.ts +16 -0
- package/dist/coverage-resolutions.js +58 -0
- package/dist/db.d.ts +37 -0
- package/dist/db.js +288 -0
- package/dist/demo.d.ts +12 -0
- package/dist/demo.js +122 -0
- package/dist/deploy-credentials.d.ts +7 -0
- package/dist/deploy-credentials.js +76 -0
- package/dist/deploy-targets/github-pages.d.ts +3 -0
- package/dist/deploy-targets/github-pages.js +100 -0
- package/dist/deploy-targets/index.d.ts +8 -0
- package/dist/deploy-targets/index.js +78 -0
- package/dist/deploy-targets/netlify.d.ts +3 -0
- package/dist/deploy-targets/netlify.js +49 -0
- package/dist/deploy-targets/types.d.ts +32 -0
- package/dist/deploy-targets/types.js +2 -0
- package/dist/deploy-targets/vercel.d.ts +3 -0
- package/dist/deploy-targets/vercel.js +95 -0
- package/dist/deploy.d.ts +9 -0
- package/dist/deploy.js +87 -13
- package/dist/deterministic-capture.d.ts +90 -0
- package/dist/deterministic-capture.js +435 -0
- package/dist/direct-edit.d.ts +40 -0
- package/dist/direct-edit.js +159 -0
- package/dist/docs-crawl.d.ts +86 -0
- package/dist/docs-crawl.js +536 -0
- package/dist/docs-site.d.ts +49 -0
- package/dist/docs-site.js +233 -0
- package/dist/doctor.js +8 -0
- package/dist/documentation-collections.d.ts +23 -0
- package/dist/documentation-collections.js +191 -0
- package/dist/documentation-plan.d.ts +253 -0
- package/dist/documentation-plan.js +2563 -0
- package/dist/doxbrix-build.d.ts +19 -0
- package/dist/doxbrix-build.js +167 -0
- package/dist/doxbrix-markdown.d.ts +9 -0
- package/dist/doxbrix-markdown.js +115 -14
- package/dist/drift.d.ts +10 -0
- package/dist/drift.js +164 -0
- package/dist/evaluation.d.ts +46 -0
- package/dist/evaluation.js +113 -0
- package/dist/evidence-pack.d.ts +47 -0
- package/dist/evidence-pack.js +358 -0
- package/dist/evidence.d.ts +25 -0
- package/dist/evidence.js +175 -0
- package/dist/fs.d.ts +8 -2
- package/dist/fs.js +41 -11
- package/dist/generator-api.d.ts +89 -0
- package/dist/generator-preflight.d.ts +27 -0
- package/dist/generator-preflight.js +105 -0
- package/dist/generator-runtime.d.ts +7 -0
- package/dist/generator-runtime.js +17 -1
- package/dist/generators.d.ts +24 -2
- package/dist/generators.js +54 -1
- package/dist/git-delivery.d.ts +17 -0
- package/dist/git-delivery.js +123 -0
- package/dist/globs.d.ts +16 -0
- package/dist/globs.js +65 -0
- package/dist/glossary.d.ts +26 -0
- package/dist/glossary.js +179 -0
- package/dist/history.d.ts +106 -0
- package/dist/history.js +600 -0
- package/dist/html-markdown.d.ts +46 -0
- package/dist/html-markdown.js +423 -0
- package/dist/interactive.js +16 -15
- package/dist/job-events.d.ts +74 -0
- package/dist/job-events.js +377 -0
- package/dist/keep-awake.d.ts +50 -0
- package/dist/keep-awake.js +123 -0
- package/dist/local-source-snapshot.d.ts +20 -0
- package/dist/local-source-snapshot.js +61 -0
- package/dist/mintlify-detect.d.ts +3 -0
- package/dist/mintlify-detect.js +18 -0
- package/dist/mintlify-import.d.ts +75 -0
- package/dist/mintlify-import.js +190 -0
- package/dist/navigation.d.ts +98 -0
- package/dist/navigation.js +310 -0
- package/dist/openapi.d.ts +60 -0
- package/dist/openapi.js +439 -0
- package/dist/page-editor-bridge.d.ts +3 -0
- package/dist/page-editor-bridge.js +109 -0
- package/dist/page-editor-preview.d.ts +10 -0
- package/dist/page-editor-preview.js +55 -0
- package/dist/page-extension.d.ts +9 -0
- package/dist/page-extension.js +15 -0
- package/dist/page-metadata.d.ts +28 -0
- package/dist/page-metadata.js +166 -0
- package/dist/page-operations.d.ts +34 -0
- package/dist/page-operations.js +215 -0
- package/dist/page-routes.d.ts +4 -0
- package/dist/page-routes.js +61 -0
- package/dist/pages.d.ts +20 -0
- package/dist/pages.js +184 -0
- package/dist/plan-generator.d.ts +3 -0
- package/dist/plan-generator.js +21 -0
- package/dist/plan-navigation.d.ts +11 -0
- package/dist/plan-navigation.js +30 -0
- package/dist/planning-captures.d.ts +20 -0
- package/dist/planning-captures.js +143 -0
- package/dist/planning-research.d.ts +135 -0
- package/dist/planning-research.js +472 -0
- package/dist/planning-triage.d.ts +23 -0
- package/dist/planning-triage.js +131 -0
- package/dist/preview.d.ts +24 -0
- package/dist/preview.js +280 -29
- package/dist/project-detect.d.ts +36 -0
- package/dist/project-detect.js +251 -0
- package/dist/project-import.d.ts +54 -0
- package/dist/project-import.js +157 -0
- package/dist/project-lock.d.ts +6 -0
- package/dist/project-lock.js +96 -0
- package/dist/project-registry.d.ts +25 -0
- package/dist/project-registry.js +79 -0
- package/dist/project.d.ts +35 -3
- package/dist/project.js +388 -38
- package/dist/prompts.d.ts +9 -0
- package/dist/prompts.js +33 -4
- package/dist/proposal-replay.d.ts +32 -0
- package/dist/proposal-replay.js +99 -0
- package/dist/quality-claims.d.ts +8 -0
- package/dist/quality-claims.js +168 -0
- package/dist/quality-config.d.ts +5 -0
- package/dist/quality-config.js +84 -0
- package/dist/quality-contract.d.ts +37 -0
- package/dist/quality-contract.js +46 -0
- package/dist/quality-examples.d.ts +4 -0
- package/dist/quality-examples.js +233 -0
- package/dist/quality-gates.d.ts +16 -0
- package/dist/quality-gates.js +192 -0
- package/dist/quality-links.d.ts +7 -0
- package/dist/quality-links.js +149 -0
- package/dist/quality-lint.d.ts +6 -0
- package/dist/quality-lint.js +124 -0
- package/dist/quality-rendered.d.ts +11 -0
- package/dist/quality-rendered.js +222 -0
- package/dist/quality-schema.d.ts +3 -0
- package/dist/quality-schema.js +71 -0
- package/dist/release-notes.d.ts +44 -0
- package/dist/release-notes.js +183 -0
- package/dist/remote-monitor.d.ts +16 -0
- package/dist/remote-monitor.js +74 -0
- package/dist/remote-source.d.ts +34 -0
- package/dist/remote-source.js +426 -0
- package/dist/review-diff.d.ts +82 -0
- package/dist/review-diff.js +400 -0
- package/dist/review-learning.d.ts +11 -0
- package/dist/review-learning.js +60 -0
- package/dist/review-render.d.ts +38 -0
- package/dist/review-render.js +224 -0
- package/dist/review-report.d.ts +9 -0
- package/dist/review-report.js +89 -0
- package/dist/review-ui.d.ts +14 -0
- package/dist/review-ui.js +1248 -0
- package/dist/schedule.d.ts +78 -0
- package/dist/schedule.js +480 -0
- package/dist/screen-capture-provider.d.ts +52 -0
- package/dist/screen-capture-provider.js +218 -0
- package/dist/screenshot-workflow.d.ts +167 -0
- package/dist/screenshot-workflow.js +1237 -0
- package/dist/settings.d.ts +1 -1
- package/dist/settings.js +95 -7
- package/dist/site-export.d.ts +18 -0
- package/dist/site-export.js +87 -0
- package/dist/source-connectors.d.ts +33 -0
- package/dist/source-connectors.js +268 -0
- package/dist/source-discovery.d.ts +132 -0
- package/dist/source-discovery.js +823 -0
- package/dist/source-intelligence.d.ts +9 -0
- package/dist/source-intelligence.js +306 -0
- package/dist/sync-review.d.ts +28 -0
- package/dist/sync-review.js +264 -0
- package/dist/sync-runs.d.ts +192 -0
- package/dist/sync-runs.js +2244 -0
- package/dist/sync.d.ts +35 -0
- package/dist/sync.js +298 -32
- package/dist/text-diff.d.ts +9 -0
- package/dist/text-diff.js +59 -0
- package/dist/types.d.ts +946 -1
- package/dist/ui/assets/doxloop-logo-light-De7Nx7j7.png +0 -0
- package/dist/ui/assets/index-BHBYU2aG.css +1 -0
- package/dist/ui/assets/index-Cq3RPQiC.js +33 -0
- package/dist/ui/index.html +18 -0
- package/dist/ui-server.d.ts +83 -0
- package/dist/ui-server.js +3532 -0
- package/dist/usage-budget.d.ts +28 -0
- package/dist/usage-budget.js +90 -0
- package/dist/validation.d.ts +25 -1
- package/dist/validation.js +312 -26
- package/dist/workspace-tools.d.ts +54 -0
- package/dist/workspace-tools.js +123 -0
- package/docs/agent-compatibility.md +50 -28
- package/docs/ci-and-automation.md +105 -66
- package/docs/doxbrix-http-api.md +8 -1
- package/docs/existing-documentation.md +80 -0
- package/docs/generation-performance.md +108 -0
- package/docs/generator-authoring.md +68 -5
- package/docs/generator-selection.md +50 -13
- package/docs/mintlify-import.md +71 -0
- package/docs/openapi-security.md +25 -0
- package/docs/project-format.md +331 -36
- package/docs/release-quality.md +158 -0
- package/docs/releasing.md +72 -0
- package/docs/review-workflows.md +51 -0
- package/docs/security-model.md +102 -39
- package/docs/troubleshooting.md +226 -93
- package/package.json +46 -15
- package/scripts/test-auto-screenshot.mjs +172 -0
- package/skills/doxloop-authoring/SKILL.md +242 -361
- package/skills/doxloop-authoring/references/existing-documentation.md +94 -0
- package/skills/doxloop-authoring/references/navigation-architecture.md +18 -7
- package/skills/doxloop-authoring/references/page-depth.md +169 -0
- package/skills/doxloop-authoring/references/project-format.md +106 -7
- package/skills/doxloop-authoring/references/quality.md +10 -0
- package/skills/doxloop-authoring/references/screenshot-manifest.md +113 -0
- package/skills/doxloop-authoring/references/screenshots.md +149 -235
- package/skills/doxloop-authoring/references/workflows.md +76 -0
- package/skills/doxloop-doxbrix/SKILL.md +38 -22
- package/skills/doxloop-doxbrix/references/api-endpoints.md +15 -14
- package/skills/doxloop-doxbrix/references/components.md +30 -3
- package/skills/doxloop-doxbrix/references/manifest.md +3 -2
- package/vendor/doxbrix-import/LICENSE +202 -0
- package/vendor/doxbrix-import/README.md +17 -0
- package/vendor/doxbrix-import/UPSTREAM.json +47 -0
- package/vendor/doxbrix-import/dist/docs/frontmatter.d.ts +13 -0
- package/vendor/doxbrix-import/dist/docs/frontmatter.js +83 -0
- package/vendor/doxbrix-import/dist/docs/import.d.ts +21 -0
- package/vendor/doxbrix-import/dist/docs/import.js +147 -0
- package/vendor/doxbrix-import/dist/docs/manifest.d.ts +163 -0
- package/vendor/doxbrix-import/dist/docs/manifest.js +64 -0
- package/vendor/doxbrix-import/dist/docs/project.d.ts +25 -0
- package/vendor/doxbrix-import/dist/docs/project.js +77 -0
- package/vendor/doxbrix-import/dist/docs/starter.d.ts +4 -0
- package/vendor/doxbrix-import/dist/docs/starter.js +11 -0
- package/vendor/doxbrix-import/dist/importer.d.ts +227 -0
- package/vendor/doxbrix-import/dist/importer.js +1567 -0
- package/vendor/doxbrix-import/dist/mintlify-openapi.d.ts +37 -0
- package/vendor/doxbrix-import/dist/mintlify-openapi.js +305 -0
- package/vendor/doxbrix-import/dist/safe-path.d.ts +9 -0
- package/vendor/doxbrix-import/dist/safe-path.js +47 -0
- package/dist/agents.d.ts.map +0 -1
- package/dist/agents.js.map +0 -1
- package/dist/args.d.ts.map +0 -1
- package/dist/args.js.map +0 -1
- package/dist/artifact-deploy.d.ts.map +0 -1
- package/dist/artifact-deploy.js.map +0 -1
- package/dist/auth.d.ts.map +0 -1
- package/dist/auth.js.map +0 -1
- package/dist/author.d.ts.map +0 -1
- package/dist/author.js.map +0 -1
- package/dist/capture.d.ts.map +0 -1
- package/dist/capture.js.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/deploy.d.ts.map +0 -1
- package/dist/deploy.js.map +0 -1
- package/dist/deployment-visibility.d.ts.map +0 -1
- package/dist/deployment-visibility.js.map +0 -1
- package/dist/doctor.d.ts.map +0 -1
- package/dist/doctor.js.map +0 -1
- package/dist/doxbrix-markdown.d.ts.map +0 -1
- package/dist/doxbrix-markdown.js.map +0 -1
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js.map +0 -1
- package/dist/fs.d.ts.map +0 -1
- package/dist/fs.js.map +0 -1
- package/dist/generator-api.d.ts.map +0 -1
- package/dist/generator-api.js.map +0 -1
- package/dist/generator-manager.d.ts.map +0 -1
- package/dist/generator-manager.js.map +0 -1
- package/dist/generator-runtime.d.ts.map +0 -1
- package/dist/generator-runtime.js.map +0 -1
- package/dist/generators.d.ts.map +0 -1
- package/dist/generators.js.map +0 -1
- package/dist/interactive.d.ts.map +0 -1
- package/dist/interactive.js.map +0 -1
- package/dist/preview.d.ts.map +0 -1
- package/dist/preview.js.map +0 -1
- package/dist/progress.d.ts.map +0 -1
- package/dist/progress.js.map +0 -1
- package/dist/project.d.ts.map +0 -1
- package/dist/project.js.map +0 -1
- package/dist/prompts.d.ts.map +0 -1
- package/dist/prompts.js.map +0 -1
- package/dist/settings.d.ts.map +0 -1
- package/dist/settings.js.map +0 -1
- package/dist/sync.d.ts.map +0 -1
- package/dist/sync.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/validation.d.ts.map +0 -1
- package/dist/validation.js.map +0 -1
- package/dist/version.d.ts.map +0 -1
- package/dist/version.js.map +0 -1
|
@@ -6,16 +6,20 @@ grouped parameters, generated request example, and response tabs.
|
|
|
6
6
|
|
|
7
7
|
- [Page contract](#page-contract)
|
|
8
8
|
- [Canonical syntax](#canonical-syntax)
|
|
9
|
-
- [
|
|
9
|
+
- [Format requirements](#format-requirements)
|
|
10
10
|
|
|
11
11
|
## Page contract
|
|
12
12
|
|
|
13
13
|
- Prefer one endpoint page and one `<ApiEndpoint>` block per operation.
|
|
14
14
|
- Use the page title for the operation name, such as `List projects`.
|
|
15
15
|
- Open with one short sentence describing the observable behavior.
|
|
16
|
-
- Put `method`, `path`, `baseUrl`,
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
- Put `method`, `path`, `baseUrl`, and `summary` on `<ApiEndpoint>`. Add
|
|
17
|
+
`description` when the operation needs more than its summary; the card shows
|
|
18
|
+
it under the summary and omits it when absent.
|
|
19
|
+
- Add one `<Param>` for every verified path, query, header, or body parameter,
|
|
20
|
+
with an `example` for each one whose value the evidence shows. Doxloop asks
|
|
21
|
+
for missing examples once per endpoint, and not at all when the section
|
|
22
|
+
already shows a verified request (a cURL or HTTP sample naming the path).
|
|
19
23
|
- Add one `<Response>` for the successful status and each important verified
|
|
20
24
|
error status.
|
|
21
25
|
- Keep example values realistic but visibly non-secret.
|
|
@@ -87,14 +91,11 @@ Do not use a Markdown parameter table, a prose-only endpoint, or separate cURL
|
|
|
87
91
|
and response fences in place of `<ApiEndpoint>`. The reader generates the
|
|
88
92
|
request presentation from the block attributes and parameter examples.
|
|
89
93
|
|
|
90
|
-
##
|
|
94
|
+
## Format requirements
|
|
91
95
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
-
|
|
95
|
-
|
|
96
|
-
-
|
|
97
|
-
|
|
98
|
-
- required and type badges are correct;
|
|
99
|
-
- the request example uses the verified base URL and parameter examples;
|
|
100
|
-
- success and error statuses appear as response tabs with valid example bodies.
|
|
96
|
+
- Every component opening tag, including `<ApiEndpoint>`, `<Param>`, and
|
|
97
|
+
`<Response>`, ends with `>` on the same physical line where it begins.
|
|
98
|
+
- Every `<Response>` carries a status, a verified `contentType`, and a valid
|
|
99
|
+
example body; success and each documented error status get their own block.
|
|
100
|
+
- The `baseUrl` and every parameter `example` are the verified values the
|
|
101
|
+
generated request presentation will show.
|
|
@@ -15,6 +15,29 @@ Run the installer and verify the executable.
|
|
|
15
15
|
</Steps>
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
+
A `<Step>` renders full block content, so a step's screenshot belongs inside
|
|
19
|
+
that step — never collected after the `<Steps>` block. Put the image directly
|
|
20
|
+
under the instruction it proves:
|
|
21
|
+
|
|
22
|
+
```mdx
|
|
23
|
+
<Steps>
|
|
24
|
+
<Step title="Open the control center">
|
|
25
|
+
Open the Overview screen at `/`.
|
|
26
|
+
|
|
27
|
+
<Frame caption="The Overview dashboard lists every workflow stage.">
|
|
28
|
+

|
|
29
|
+
</Frame>
|
|
30
|
+
</Step>
|
|
31
|
+
<Step title="Start an authoring request">
|
|
32
|
+
Select **Update** and describe a reader outcome.
|
|
33
|
+
|
|
34
|
+
<Frame caption="The Update form captures the reader outcome.">
|
|
35
|
+

|
|
36
|
+
</Frame>
|
|
37
|
+
</Step>
|
|
38
|
+
</Steps>
|
|
39
|
+
```
|
|
40
|
+
|
|
18
41
|
````mdx
|
|
19
42
|
<CodeGroup>
|
|
20
43
|
```bash npm
|
|
@@ -102,6 +125,12 @@ graph TD; A[Start] --> B[Complete];
|
|
|
102
125
|
<Math>e = mc^2</Math>
|
|
103
126
|
```
|
|
104
127
|
|
|
128
|
+
Diagrams are scaled to the content width, so a wide one becomes unreadably
|
|
129
|
+
small. Keep every level of a `graph TD` to at most three or four nodes; when
|
|
130
|
+
a decision has more outcomes, draw it `graph LR` (it grows downward instead)
|
|
131
|
+
or split it into two diagrams, and keep node labels to a few words. A table
|
|
132
|
+
often reads better than a diagram with six or more branches.
|
|
133
|
+
|
|
105
134
|
```mdx
|
|
106
135
|
<ApiEndpoint method="POST" path="/users" baseUrl="https://api.example.com" summary="Create a user">
|
|
107
136
|
<Param name="name" in="body" type="string" required>Display name</Param>
|
|
@@ -132,6 +161,4 @@ For standalone API blocks:
|
|
|
132
161
|
</ResponseExample>
|
|
133
162
|
```
|
|
134
163
|
|
|
135
|
-
Never invent a component outside this catalog.
|
|
136
|
-
inspect that component in `doxloop preview`; balanced tags alone do not prove
|
|
137
|
-
that its attributes or content are correct.
|
|
164
|
+
Never invent a component outside this catalog.
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# Doxbrix project format
|
|
2
2
|
|
|
3
|
-
The canonical manifest is `docs
|
|
4
|
-
`contentDir` is
|
|
3
|
+
The canonical manifest is `docs.json` at the project root for a new native
|
|
4
|
+
Doxbrix project whose `contentDir` is empty. Existing projects with
|
|
5
|
+
`contentDir: "docs"` keep the manifest at `docs/docs.json`.
|
|
5
6
|
|
|
6
7
|
```json
|
|
7
8
|
{
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Doxbrix conversion engine
|
|
2
|
+
|
|
3
|
+
These SDK conversion modules, CLI file-import helpers, and SDK regression tests
|
|
4
|
+
are copied unchanged from the Doxbrix 0.1.4 source supplied for this integration.
|
|
5
|
+
`UPSTREAM.json` records the source revision and SHA-256 of every copied file.
|
|
6
|
+
The working-tree file hashes identify the exact snapshot, including changes
|
|
7
|
+
that may not have been committed at that revision.
|
|
8
|
+
|
|
9
|
+
Do not implement a second Mintlify transformer here. Refresh these files together
|
|
10
|
+
from upstream and run both the original regression suite and Doxloop's import
|
|
11
|
+
integration tests. The wrapper in `src/mintlify-import.ts` owns source selection,
|
|
12
|
+
safe remote fetching, staging, reporting, and Doxloop project adoption.
|
|
13
|
+
|
|
14
|
+
The engine compiles separately with its original optional-property semantics;
|
|
15
|
+
Doxloop consumes the generated JavaScript and declarations. `build:importer`
|
|
16
|
+
runs before core compilation and typechecking. Built files and the Apache-2.0
|
|
17
|
+
license ship with Doxloop; no separately installed CLI or local checkout is needed.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"source": "Doxbrix SDK and CLI conversion modules",
|
|
3
|
+
"version": "0.1.4",
|
|
4
|
+
"revision": "93b727c7b5617540498d034f1b2a839d125ad3e5",
|
|
5
|
+
"files": [
|
|
6
|
+
{
|
|
7
|
+
"file": "importer.ts",
|
|
8
|
+
"sha256": "1b021d6509651e7de48fdeb8e2dcd9866fc1db4c6e27508bb58b14b871a071b0"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"file": "mintlify-openapi.ts",
|
|
12
|
+
"sha256": "509902e58f2ca2d9353165f170a0e3af7d624c6310c917530ea253c5e9b244a7"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"file": "importer.test.ts",
|
|
16
|
+
"sha256": "b5bd0bff3432516a2832581ed7a0bf31fe86f11eac0546c8aadd814e080c4372"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"file": "docs/import.ts",
|
|
20
|
+
"sha256": "65c9101568258a21f73bedd0002627ade2af6aa3d6be924a40e4bff19afadbcd"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"file": "docs/project.ts",
|
|
24
|
+
"sha256": "19c7ea839459195c5fa9707728bd540bba4c45b2f19bd69ed7f4032bdf2454ad"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"file": "docs/frontmatter.ts",
|
|
28
|
+
"sha256": "dacef357d9d5a4c7ec77f24078ccaa7a99abcb45271118e7066dc0ecf47d5afb"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"file": "docs/manifest.ts",
|
|
32
|
+
"sha256": "7d5e4fc0a84550509fb508d00f3dc1353803377b682c061b585925d964ce534f"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"file": "docs/starter.ts",
|
|
36
|
+
"sha256": "27a830733e9a87ba2875707322fc48bfd7c3d1de56b433fb667c7176c09fdcb3"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"file": "safe-path.ts",
|
|
40
|
+
"sha256": "71570233498d6809db3b1f7399c10621f08393fcbe9f339eb37562ee511a71eb"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"file": "docs/import.test.ts",
|
|
44
|
+
"sha256": "a801faf4b98e49b2a2df56810254105e01054f8fa291d7b972f7988c60126115"
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal frontmatter reader/writer for the CLI's lint + bundle steps. Handles
|
|
3
|
+
* the common YAML subset Doxbrix page files use: `key: value`, quoted strings,
|
|
4
|
+
* booleans, numbers, inline `[a, b]` arrays, and `-` list items. The SERVER
|
|
5
|
+
* re-parses authoritatively on push (`gitFileToPage`), so this only needs to be
|
|
6
|
+
* good enough for local validation and display.
|
|
7
|
+
*/
|
|
8
|
+
export interface ParsedFrontmatter {
|
|
9
|
+
data: Record<string, unknown>;
|
|
10
|
+
body: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function parseFrontmatter(source: string): ParsedFrontmatter;
|
|
13
|
+
export declare function serializeFrontmatter(data: Record<string, unknown>, body: string): string;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal frontmatter reader/writer for the CLI's lint + bundle steps. Handles
|
|
3
|
+
* the common YAML subset Doxbrix page files use: `key: value`, quoted strings,
|
|
4
|
+
* booleans, numbers, inline `[a, b]` arrays, and `-` list items. The SERVER
|
|
5
|
+
* re-parses authoritatively on push (`gitFileToPage`), so this only needs to be
|
|
6
|
+
* good enough for local validation and display.
|
|
7
|
+
*/
|
|
8
|
+
const FRONTMATTER_RE = /^?---\r?\n([\s\S]*?)\r?\n---\r?\n?/;
|
|
9
|
+
export function parseFrontmatter(source) {
|
|
10
|
+
const match = FRONTMATTER_RE.exec(source);
|
|
11
|
+
if (!match)
|
|
12
|
+
return { data: {}, body: source.replace(/^/, '') };
|
|
13
|
+
const data = parseYamlSubset(match[1] ?? '');
|
|
14
|
+
return { data, body: source.slice(match[0].length) };
|
|
15
|
+
}
|
|
16
|
+
export function serializeFrontmatter(data, body) {
|
|
17
|
+
const entries = Object.entries(data).filter(([, v]) => v !== undefined && v !== null && v !== '');
|
|
18
|
+
if (entries.length === 0)
|
|
19
|
+
return body;
|
|
20
|
+
const lines = entries.map(([key, value]) => `${key}: ${serializeValue(value)}`);
|
|
21
|
+
return `---\n${lines.join('\n')}\n---\n${body}`;
|
|
22
|
+
}
|
|
23
|
+
function serializeValue(value) {
|
|
24
|
+
if (Array.isArray(value))
|
|
25
|
+
return `[${value.map((v) => serializeScalar(v)).join(', ')}]`;
|
|
26
|
+
return serializeScalar(value);
|
|
27
|
+
}
|
|
28
|
+
function serializeScalar(value) {
|
|
29
|
+
if (typeof value === 'boolean' || typeof value === 'number')
|
|
30
|
+
return String(value);
|
|
31
|
+
const s = String(value);
|
|
32
|
+
return /[:#\[\]{}]|^\s|\s$/.test(s) ? JSON.stringify(s) : s;
|
|
33
|
+
}
|
|
34
|
+
function parseYamlSubset(block) {
|
|
35
|
+
const out = {};
|
|
36
|
+
const lines = block.split(/\r?\n/);
|
|
37
|
+
let i = 0;
|
|
38
|
+
while (i < lines.length) {
|
|
39
|
+
const line = lines[i];
|
|
40
|
+
i++;
|
|
41
|
+
if (!line.trim() || line.trimStart().startsWith('#'))
|
|
42
|
+
continue;
|
|
43
|
+
const m = /^([A-Za-z0-9_-]+):\s*(.*)$/.exec(line);
|
|
44
|
+
if (!m)
|
|
45
|
+
continue;
|
|
46
|
+
const key = m[1];
|
|
47
|
+
const rest = (m[2] ?? '').trim();
|
|
48
|
+
if (rest === '') {
|
|
49
|
+
// Possibly a `-` list on following indented lines.
|
|
50
|
+
const items = [];
|
|
51
|
+
while (i < lines.length && /^\s*-\s+/.test(lines[i])) {
|
|
52
|
+
items.push(coerceScalar(lines[i].replace(/^\s*-\s+/, '').trim()));
|
|
53
|
+
i++;
|
|
54
|
+
}
|
|
55
|
+
out[key] = items.length ? items : '';
|
|
56
|
+
}
|
|
57
|
+
else if (rest.startsWith('[') && rest.endsWith(']')) {
|
|
58
|
+
out[key] = rest
|
|
59
|
+
.slice(1, -1)
|
|
60
|
+
.split(',')
|
|
61
|
+
.map((s) => coerceScalar(s.trim()))
|
|
62
|
+
.filter((s) => s !== '');
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
out[key] = coerceScalar(rest);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return out;
|
|
69
|
+
}
|
|
70
|
+
function coerceScalar(raw) {
|
|
71
|
+
if (raw === '')
|
|
72
|
+
return '';
|
|
73
|
+
if ((raw.startsWith('"') && raw.endsWith('"')) || (raw.startsWith("'") && raw.endsWith("'"))) {
|
|
74
|
+
return raw.slice(1, -1);
|
|
75
|
+
}
|
|
76
|
+
if (raw === 'true')
|
|
77
|
+
return true;
|
|
78
|
+
if (raw === 'false')
|
|
79
|
+
return false;
|
|
80
|
+
if (/^-?\d+(\.\d+)?$/.test(raw))
|
|
81
|
+
return Number(raw);
|
|
82
|
+
return raw;
|
|
83
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface SourceFile {
|
|
2
|
+
path: string;
|
|
3
|
+
content: string;
|
|
4
|
+
}
|
|
5
|
+
/** Collect non-page assets before conversion writes into its output directory. */
|
|
6
|
+
export declare function collectSourceAssets(dir: string): string[];
|
|
7
|
+
/** Copy imported images, fonts, media, styles, and API specs without flattening paths. */
|
|
8
|
+
export declare function copySourceAssets(sourceDir: string, docsDir: string, assets: string[]): number;
|
|
9
|
+
/** Collect text source files under `dir` (skips binaries/large/media). */
|
|
10
|
+
export declare function collectSourceFiles(dir: string): SourceFile[];
|
|
11
|
+
/** Write a converted manifest + page files into `docsDir`. */
|
|
12
|
+
export declare function writeConvertResult(docsDir: string, result: {
|
|
13
|
+
manifest: unknown;
|
|
14
|
+
pages: {
|
|
15
|
+
path: string;
|
|
16
|
+
markdown: string;
|
|
17
|
+
}[];
|
|
18
|
+
}): {
|
|
19
|
+
manifestPath: string;
|
|
20
|
+
pageCount: number;
|
|
21
|
+
};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { copyFileSync, readFileSync, writeFileSync, mkdirSync, rmSync, statSync } from 'node:fs';
|
|
2
|
+
import { join, dirname, posix } from 'node:path';
|
|
3
|
+
import { listFilesRecursive } from './project.js';
|
|
4
|
+
import { stringifyManifest, withPageExtension } from './manifest.js';
|
|
5
|
+
import { assertSafeWriteParent, resolveWithin } from '../safe-path.js';
|
|
6
|
+
import { hasStarterPageContent } from './starter.js';
|
|
7
|
+
/** Text extensions / filenames worth uploading for dialect detection + conversion. */
|
|
8
|
+
const TEXT_EXTS = ['.md', '.mdx', '.markdown', '.json', '.yaml', '.yml', '.txt', '.css'];
|
|
9
|
+
const TEXT_NAMES = ['summary', 'mint.json', 'docs.json', '.gitbook.yaml', '.gitbook.yml', 'readme'];
|
|
10
|
+
const MAX_FILES = 4000;
|
|
11
|
+
const MAX_BYTES = 2 * 1024 * 1024; // per file
|
|
12
|
+
/** Assets that can be rendered or are referenced by imported documentation. */
|
|
13
|
+
const ASSET_EXTS = new Set([
|
|
14
|
+
'.png', '.jpg', '.jpeg', '.webp', '.gif', '.svg', '.ico', '.avif', '.bmp',
|
|
15
|
+
'.mp4', '.webm', '.mov', '.mp3', '.wav', '.ogg', '.pdf',
|
|
16
|
+
'.woff', '.woff2', '.ttf', '.otf', '.eot',
|
|
17
|
+
'.json', '.yaml', '.yml',
|
|
18
|
+
]);
|
|
19
|
+
const SOURCE_CONFIGS = new Set(['docs.json', 'mint.json', '.gitbook.yaml', '.gitbook.yml']);
|
|
20
|
+
const SOURCE_TOOLING_FILES = new Set([
|
|
21
|
+
'package.json', 'package-lock.json', 'pnpm-lock.yaml', 'yarn.lock', 'bun.lock', 'bun.lockb',
|
|
22
|
+
'tsconfig.json', 'jsconfig.json', 'biome.json', 'deno.json', 'deno.jsonc',
|
|
23
|
+
]);
|
|
24
|
+
/** Collect non-page assets before conversion writes into its output directory. */
|
|
25
|
+
export function collectSourceAssets(dir) {
|
|
26
|
+
const assets = [];
|
|
27
|
+
for (const rel of listFilesRecursive(dir)) {
|
|
28
|
+
const normalized = rel.replace(/\\/g, '/');
|
|
29
|
+
const base = normalized.split('/').pop()?.toLowerCase() ?? '';
|
|
30
|
+
if (/^(?:\.git|\.github|\.gitlab|node_modules|scripts|bin)\//.test(normalized))
|
|
31
|
+
continue;
|
|
32
|
+
if (SOURCE_TOOLING_FILES.has(base) || /^tsconfig\..*\.json$/.test(base))
|
|
33
|
+
continue;
|
|
34
|
+
const dot = base.lastIndexOf('.');
|
|
35
|
+
const ext = dot >= 0 ? base.slice(dot) : '';
|
|
36
|
+
if (!ASSET_EXTS.has(ext) || SOURCE_CONFIGS.has(base))
|
|
37
|
+
continue;
|
|
38
|
+
assets.push(normalized);
|
|
39
|
+
}
|
|
40
|
+
return assets;
|
|
41
|
+
}
|
|
42
|
+
/** Copy imported images, fonts, media, styles, and API specs without flattening paths. */
|
|
43
|
+
export function copySourceAssets(sourceDir, docsDir, assets) {
|
|
44
|
+
let copied = 0;
|
|
45
|
+
for (const rel of assets) {
|
|
46
|
+
const source = resolveWithin(sourceDir, rel);
|
|
47
|
+
const destination = resolveWithin(docsDir, rel);
|
|
48
|
+
// Root-level imports already have assets in place. Never copy a file onto itself.
|
|
49
|
+
if (source === destination)
|
|
50
|
+
continue;
|
|
51
|
+
try {
|
|
52
|
+
assertSafeWriteParent(docsDir, destination);
|
|
53
|
+
mkdirSync(dirname(destination), { recursive: true });
|
|
54
|
+
copyFileSync(source, destination);
|
|
55
|
+
copied += 1;
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
// Keep migration resilient; the command reports the number successfully copied.
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return copied;
|
|
62
|
+
}
|
|
63
|
+
/** Collect text source files under `dir` (skips binaries/large/media). */
|
|
64
|
+
export function collectSourceFiles(dir) {
|
|
65
|
+
const listed = listFilesRecursive(dir).map((rel) => rel.replace(/\\/g, '/'));
|
|
66
|
+
const available = new Set(listed);
|
|
67
|
+
const files = [];
|
|
68
|
+
const collected = new Set();
|
|
69
|
+
const add = (rel) => {
|
|
70
|
+
if (files.length >= MAX_FILES)
|
|
71
|
+
return;
|
|
72
|
+
const lower = rel.toLowerCase();
|
|
73
|
+
const base = lower.split('/').pop() ?? '';
|
|
74
|
+
const isText = TEXT_EXTS.some((e) => lower.endsWith(e)) || TEXT_NAMES.some((n) => base === n || base.startsWith(n + '.'));
|
|
75
|
+
if (!isText || collected.has(rel))
|
|
76
|
+
return;
|
|
77
|
+
const abs = join(dir, rel);
|
|
78
|
+
try {
|
|
79
|
+
if (statSync(abs).size > MAX_BYTES)
|
|
80
|
+
return;
|
|
81
|
+
files.push({ path: rel, content: readFileSync(abs, 'utf8') });
|
|
82
|
+
collected.add(rel);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
// unreadable — skip
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
for (const rel of listed) {
|
|
89
|
+
if (files.length >= MAX_FILES)
|
|
90
|
+
break;
|
|
91
|
+
add(rel);
|
|
92
|
+
}
|
|
93
|
+
// React SVG icons and other non-executing snippets are sometimes stored in
|
|
94
|
+
// .js/.jsx/.ts/.tsx modules. Follow only modules explicitly imported by a
|
|
95
|
+
// collected documentation file; never scan arbitrary application source.
|
|
96
|
+
for (let index = 0; index < files.length && files.length < MAX_FILES; index += 1) {
|
|
97
|
+
const sourceFile = files[index];
|
|
98
|
+
for (const match of sourceFile.content.matchAll(/\bfrom\s*["']([^"']+\.(?:js|jsx|ts|tsx))["']/g)) {
|
|
99
|
+
const specifier = match[1];
|
|
100
|
+
const target = posix.normalize(specifier.startsWith('/')
|
|
101
|
+
? specifier.slice(1)
|
|
102
|
+
: posix.join(posix.dirname(sourceFile.path), specifier));
|
|
103
|
+
if (target === '..' || target.startsWith('../') || !available.has(target) || collected.has(target))
|
|
104
|
+
continue;
|
|
105
|
+
const abs = join(dir, target);
|
|
106
|
+
try {
|
|
107
|
+
if (statSync(abs).size > MAX_BYTES)
|
|
108
|
+
continue;
|
|
109
|
+
files.push({ path: target, content: readFileSync(abs, 'utf8') });
|
|
110
|
+
collected.add(target);
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
// unreadable — skip
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return files;
|
|
118
|
+
}
|
|
119
|
+
/** Write a converted manifest + page files into `docsDir`. */
|
|
120
|
+
export function writeConvertResult(docsDir, result) {
|
|
121
|
+
mkdirSync(docsDir, { recursive: true });
|
|
122
|
+
const generatedPages = new Set(result.pages.map((page) => withPageExtension(page.path)));
|
|
123
|
+
// `dxb init` creates two useful starter pages. A repository import replaces
|
|
124
|
+
// those only when the source does not contain the same routes; never remove
|
|
125
|
+
// user-authored pages or any path produced by this conversion.
|
|
126
|
+
for (const rel of listFilesRecursive(docsDir)) {
|
|
127
|
+
if (!/\.(?:md|mdx)$/i.test(rel) || generatedPages.has(rel))
|
|
128
|
+
continue;
|
|
129
|
+
const absolute = resolveWithin(docsDir, rel);
|
|
130
|
+
try {
|
|
131
|
+
if (hasStarterPageContent(readFileSync(absolute, 'utf8')))
|
|
132
|
+
rmSync(absolute);
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
// A concurrent or unreadable file is preserved rather than risking data loss.
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
const manifestPath = join(docsDir, 'docs.json');
|
|
139
|
+
writeFileSync(manifestPath, stringifyManifest(result.manifest));
|
|
140
|
+
for (const page of result.pages) {
|
|
141
|
+
const abs = resolveWithin(docsDir, withPageExtension(page.path));
|
|
142
|
+
assertSafeWriteParent(docsDir, abs);
|
|
143
|
+
mkdirSync(dirname(abs), { recursive: true });
|
|
144
|
+
writeFileSync(abs, page.markdown);
|
|
145
|
+
}
|
|
146
|
+
return { manifestPath, pageCount: result.pages.length };
|
|
147
|
+
}
|