docmedown 0.1.4 → 0.1.6
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/cli.js +3 -2
- package/dist/docmedown.cjs +58 -58
- package/dist/docmedown.iife.js +292 -292
- package/dist/docmedown.mjs +5245 -5122
- package/dist/types/runtime/config-schema.d.ts +2 -0
- package/dist/types/runtime/home.d.ts +47 -0
- package/dist/types/runtime/provider/DocProvider.d.ts +2 -0
- package/package.json +2 -2
- package/schemas/docs.schema.json +5 -0
- package/templates/docs.json +1 -0
|
@@ -148,6 +148,7 @@ export declare const docConfigSchema: z.ZodObject<{
|
|
|
148
148
|
description: z.ZodOptional<z.ZodString>;
|
|
149
149
|
version: z.ZodOptional<z.ZodString>;
|
|
150
150
|
rootDoc: z.ZodOptional<z.ZodString>;
|
|
151
|
+
home: z.ZodOptional<z.ZodString>;
|
|
151
152
|
source: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
152
153
|
type: z.ZodLiteral<"github">;
|
|
153
154
|
repo: z.ZodString;
|
|
@@ -266,6 +267,7 @@ export declare const normalizedDocConfigSchema: z.ZodObject<{
|
|
|
266
267
|
description: z.ZodOptional<z.ZodString>;
|
|
267
268
|
version: z.ZodOptional<z.ZodString>;
|
|
268
269
|
rootDoc: z.ZodOptional<z.ZodString>;
|
|
270
|
+
home: z.ZodOptional<z.ZodString>;
|
|
269
271
|
source: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
270
272
|
type: z.ZodLiteral<"github">;
|
|
271
273
|
repo: z.ZodString;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Documentation home resolution.
|
|
3
|
+
*
|
|
4
|
+
* Resolution order for the Home action:
|
|
5
|
+
* 1. Explicit `home` setting (document path/slug, or a link escape hatch).
|
|
6
|
+
* 2. Root-level README.md, PROJECT.md, ABOUT.md, INDEX.md — case-sensitive pass.
|
|
7
|
+
* 3. The same candidates again case-insensitively.
|
|
8
|
+
* 4. The alphabetically first Markdown document in the corpus.
|
|
9
|
+
*
|
|
10
|
+
* Documentation inside documentation: when an ancestor documentation manifest is
|
|
11
|
+
* reachable, Home links to the original (outermost) documentation home instead.
|
|
12
|
+
*/
|
|
13
|
+
export declare const HOME_CANDIDATE_FILES: readonly ["README.md", "PROJECT.md", "ABOUT.md", "INDEX.md"];
|
|
14
|
+
/** How many directory levels upward to probe for an enclosing documentation root. */
|
|
15
|
+
export declare const ORIGINAL_HOME_MAX_ANCESTORS = 3;
|
|
16
|
+
export interface HomeDocumentInput {
|
|
17
|
+
slug?: string;
|
|
18
|
+
path?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface HomeConfigInput {
|
|
21
|
+
home?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ResolvedHome {
|
|
24
|
+
kind: "route" | "href";
|
|
25
|
+
slug?: string;
|
|
26
|
+
href?: string;
|
|
27
|
+
/** Set when the home was resolved from an enclosing documentation root. */
|
|
28
|
+
via?: "ancestor";
|
|
29
|
+
}
|
|
30
|
+
export interface MinimalFetchResponse {
|
|
31
|
+
ok: boolean;
|
|
32
|
+
json: () => Promise<unknown>;
|
|
33
|
+
}
|
|
34
|
+
export type MinimalFetch = (input: string) => Promise<MinimalFetchResponse>;
|
|
35
|
+
/**
|
|
36
|
+
* Resolves the documentation home from a corpus of documents. `docs` accepts
|
|
37
|
+
* manifest items, sidebar nodes, or bare file paths.
|
|
38
|
+
*/
|
|
39
|
+
export declare function resolveDocumentationHome(docs: HomeDocumentInput[] | null | undefined, config?: HomeConfigInput | null): ResolvedHome | null;
|
|
40
|
+
/**
|
|
41
|
+
* Detects documentation inside documentation by probing ancestor directories
|
|
42
|
+
* for an enclosing DocMeDown manifest. Returns the original documentation home
|
|
43
|
+
* as a page-relative link, or null when no ancestor documentation exists.
|
|
44
|
+
*/
|
|
45
|
+
export declare function findOriginalDocumentationHome(fetchImpl: MinimalFetch, options?: {
|
|
46
|
+
levels?: number;
|
|
47
|
+
}): Promise<ResolvedHome | null>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type React from "react";
|
|
2
|
+
import { type ResolvedHome } from "../home";
|
|
2
3
|
import { type ParsedMarkdown } from "../markdown/parser";
|
|
3
4
|
import { HashRouter } from "../router";
|
|
4
5
|
import { DocSearchIndex } from "../search/search-index";
|
|
@@ -22,6 +23,7 @@ interface DocContextType {
|
|
|
22
23
|
error: string | null;
|
|
23
24
|
prevDoc: NavDocItem | null;
|
|
24
25
|
nextDoc: NavDocItem | null;
|
|
26
|
+
home: ResolvedHome | null;
|
|
25
27
|
isSearchOpen: boolean;
|
|
26
28
|
setIsSearchOpen: (open: boolean) => void;
|
|
27
29
|
isMobileSidebarOpen: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docmedown",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "The simplest MarkDown documenter yet. CLI & Web Script React SPA documentation engine.",
|
|
5
5
|
"main": "./dist/docmedown.cjs",
|
|
6
6
|
"module": "./dist/docmedown.mjs",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"build:docs:watch": "node ./bin/docmedown.js build ./docs --watch",
|
|
47
47
|
"build:offline": "node ./bin/docmedown.js build ./docs",
|
|
48
48
|
"config:docs": "node ./bin/docmedown.js config ./docs/docs.json",
|
|
49
|
-
"test": "npx tsx --test tests/parser.test.ts tests/scanner.test.ts tests/theme-schema.test.ts tests/runtime-integration.test.ts tests/package-smoke.test.ts tests/hosting.test.ts",
|
|
49
|
+
"test": "npx tsx --test tests/parser.test.ts tests/scanner.test.ts tests/theme-schema.test.ts tests/runtime-integration.test.ts tests/package-smoke.test.ts tests/hosting.test.ts tests/deploy.test.ts tests/home.test.ts",
|
|
50
50
|
"test:artifacts": "npx tsx --test tests/offline-artifact.test.ts",
|
|
51
51
|
"test:release": "npm run typecheck && npm run lint && npm run test && npm run build && npm run build:docs && npm run test:artifacts && npm pack --dry-run",
|
|
52
52
|
"deploy": "node ./scripts/deploy.mjs",
|
package/schemas/docs.schema.json
CHANGED
|
@@ -12,6 +12,11 @@
|
|
|
12
12
|
"description": { "type": "string" },
|
|
13
13
|
"version": { "type": "string" },
|
|
14
14
|
"rootDoc": { "type": "string", "minLength": 1 },
|
|
15
|
+
"home": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"minLength": 1,
|
|
18
|
+
"description": "Documentation home document (path or slug) or an explicit link. Defaults to README.md, PROJECT.md, ABOUT.md, or INDEX.md at the documentation root (case-sensitive pass first, then case-insensitive), then the alphabetically first Markdown document."
|
|
19
|
+
},
|
|
15
20
|
"source": { "$ref": "#/$defs/source" },
|
|
16
21
|
"theme": { "$ref": "#/$defs/theme" },
|
|
17
22
|
"nav": { "type": "array", "items": { "$ref": "#/$defs/navLink" } },
|