docmedown 0.1.0 → 0.1.1

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 (32) hide show
  1. package/README.md +31 -0
  2. package/dist/cli.js +665 -507
  3. package/dist/docmedown.cjs +105 -41
  4. package/dist/docmedown.iife.js +106 -42
  5. package/dist/docmedown.mjs +7753 -4477
  6. package/dist/types/runtime/app.d.ts +3 -3
  7. package/dist/types/runtime/components/Builtins.d.ts +3 -3
  8. package/dist/types/runtime/components/Content.d.ts +1 -1
  9. package/dist/types/runtime/components/DmdRegistry.d.ts +1 -1
  10. package/dist/types/runtime/components/Layout.d.ts +1 -1
  11. package/dist/types/runtime/components/Navbar.d.ts +1 -1
  12. package/dist/types/runtime/components/Sidebar.d.ts +1 -1
  13. package/dist/types/runtime/components/TableOfContents.d.ts +2 -2
  14. package/dist/types/runtime/config-schema.d.ts +344 -0
  15. package/dist/types/runtime/config.d.ts +10 -3
  16. package/dist/types/runtime/index.d.ts +6 -5
  17. package/dist/types/runtime/loader/auto-indexer.d.ts +1 -1
  18. package/dist/types/runtime/loader/local-loader.d.ts +1 -1
  19. package/dist/types/runtime/loader/remote-github.d.ts +2 -2
  20. package/dist/types/runtime/loader/remote-gitlab.d.ts +2 -2
  21. package/dist/types/runtime/markdown/callouts.d.ts +1 -1
  22. package/dist/types/runtime/markdown/highlighter.d.ts +16 -16
  23. package/dist/types/runtime/markdown/parser.d.ts +1 -1
  24. package/dist/types/runtime/markdown/renderer.d.ts +1 -1
  25. package/dist/types/runtime/provider/DocProvider.d.ts +5 -5
  26. package/dist/types/runtime/provider/ThemeProvider.d.ts +3 -3
  27. package/dist/types/runtime/search/SearchModal.d.ts +2 -2
  28. package/dist/types/runtime/search/search-index.d.ts +1 -1
  29. package/dist/types/runtime/types.d.ts +25 -99
  30. package/package.json +11 -3
  31. package/schemas/docs.schema.json +157 -0
  32. package/templates/docs.json +1 -0
@@ -1,103 +1,29 @@
1
- /**
2
- * DocMeDown Configuration and Runtime Type Definitions
3
- */
4
- export type ThemePreset = 'indigo' | 'emerald' | 'sunset' | 'violet' | 'rose' | 'slate' | 'cyberpunk';
5
- export type ColorMode = 'light' | 'dark' | 'auto';
6
- export interface NavLink {
7
- label: string;
8
- href: string;
9
- external?: boolean;
10
- icon?: string;
11
- }
12
- export interface SocialLink {
13
- type: 'github' | 'gitlab' | 'twitter' | 'x' | 'discord' | 'custom';
14
- url: string;
15
- label?: string;
16
- icon?: string;
17
- }
18
- export interface RemoteSourceConfig {
19
- type: 'github' | 'gitlab' | 'raw';
20
- /** e.g. "facebook/react" or "owner/repo" */
21
- repo?: string;
22
- /** e.g. "main" or "master" */
23
- branch?: string;
24
- /** Subdirectory where markdown files live, e.g. "docs" or "" */
25
- docsDir?: string;
26
- /** Optional personal access token or auth for private repos */
27
- token?: string;
28
- /** Raw base URL override */
29
- baseUrl?: string;
30
- }
31
- export interface SidebarItemConfig {
32
- title?: string;
33
- path?: string;
34
- slug?: string;
35
- icon?: string;
36
- badge?: string;
37
- badgeType?: 'info' | 'success' | 'warning' | 'new';
38
- collapsed?: boolean;
39
- children?: SidebarItemConfig[];
40
- }
41
- export interface DocThemeConfig {
42
- preset?: ThemePreset;
43
- defaultMode?: ColorMode;
44
- accentColor?: string;
45
- accentColorDark?: string;
46
- fontFamily?: string;
47
- codeTheme?: 'github' | 'dracula' | 'one-dark' | 'synthwave';
48
- logo?: {
49
- light?: string;
50
- dark?: string;
51
- alt?: string;
52
- text?: string;
53
- };
54
- favicon?: string;
55
- }
56
- export interface DocSearchConfig {
57
- enabled?: boolean;
58
- placeholder?: string;
59
- maxResults?: number;
60
- }
61
- export interface DocConfig {
62
- name: string;
63
- tagline?: string;
64
- description?: string;
65
- version?: string;
66
- rootDoc?: string;
67
- /** Source configuration: local filesystem or remote GitHub/GitLab */
68
- source?: RemoteSourceConfig;
69
- /** Visual and theme configurations */
70
- theme?: DocThemeConfig;
71
- /** Navigation bar links */
72
- nav?: NavLink[];
73
- /** Social and repository links */
74
- socials?: SocialLink[];
75
- /** Manual sidebar configuration (optional; auto-indexed if omitted) */
76
- sidebar?: SidebarItemConfig[];
77
- /** Auto-indexing options */
78
- autoIndex?: {
79
- enabled?: boolean;
80
- exclude?: string[];
81
- sort?: 'alphabetical' | 'frontmatter' | 'natural';
82
- defaultCollapsed?: boolean;
83
- };
84
- /** Search options */
85
- search?: DocSearchConfig;
86
- /** Footer config */
87
- footer?: {
88
- copyright?: string;
89
- links?: NavLink[];
90
- showBuiltWith?: boolean;
91
- };
92
- /** Custom component directory or URL */
93
- componentsUrl?: string;
94
- /** Edit page link (e.g. "https://github.com/owner/repo/edit/main/docs/") */
95
- editUrl?: string;
96
- }
1
+ /** DocMeDown runtime type definitions. Configuration types are derived from Zod schemas. */
2
+ import type { z } from "zod";
3
+ import type { colorModeSchema, docConfigSchema, docSearchConfigSchema, docThemeConfigSchema, navLinkSchema, normalizedDocConfigSchema, remoteSourceSchema, SidebarItemConfigShape, socialLinkSchema, themePresetSchema } from "./config-schema";
4
+ export type ThemePreset = z.infer<typeof themePresetSchema>;
5
+ export type ColorMode = z.infer<typeof colorModeSchema>;
6
+ export type NavLink = z.infer<typeof navLinkSchema>;
7
+ export type SocialLink = z.infer<typeof socialLinkSchema>;
8
+ export type RemoteSourceConfig = z.infer<typeof remoteSourceSchema>;
9
+ export type GithubSourceConfig = Extract<RemoteSourceConfig, {
10
+ type: "github";
11
+ }>;
12
+ export type GitlabSourceConfig = Extract<RemoteSourceConfig, {
13
+ type: "gitlab";
14
+ }>;
15
+ export type RawSourceConfig = Extract<RemoteSourceConfig, {
16
+ type: "raw";
17
+ }>;
18
+ export type SidebarItemConfig = SidebarItemConfigShape;
19
+ export type DocThemeConfig = z.infer<typeof docThemeConfigSchema>;
20
+ export type DocSearchConfig = z.infer<typeof docSearchConfigSchema>;
21
+ export type PartialDocConfig = z.input<typeof docConfigSchema>;
22
+ export type DocConfig = z.output<typeof normalizedDocConfigSchema>;
97
23
  /** Options accepted by the browser integration entry point. */
98
24
  export interface DocMeDownInitOptions {
99
25
  el?: string | HTMLElement;
100
- config?: Partial<DocConfig>;
26
+ config?: PartialDocConfig;
101
27
  basePath?: string;
102
28
  }
103
29
  /** Handle returned after mounting DocMeDown into a page. */
@@ -118,7 +44,7 @@ export interface DocFrontmatter {
118
44
  description?: string;
119
45
  icon?: string;
120
46
  badge?: string;
121
- badge_type?: 'info' | 'success' | 'warning' | 'new';
47
+ badge_type?: "info" | "success" | "warning" | "new";
122
48
  tags?: string[];
123
49
  hidden?: boolean;
124
50
  [key: string]: any;
@@ -148,7 +74,7 @@ export interface SidebarTreeNode {
148
74
  path?: string;
149
75
  icon?: string;
150
76
  badge?: string;
151
- badgeType?: 'info' | 'success' | 'warning' | 'new';
77
+ badgeType?: "info" | "success" | "warning" | "new";
152
78
  order: number;
153
79
  isCategory: boolean;
154
80
  collapsed?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docmedown",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
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",
@@ -23,6 +23,7 @@
23
23
  "dist",
24
24
  "bin",
25
25
  "templates",
26
+ "schemas",
26
27
  "README.md",
27
28
  "LICENSE"
28
29
  ],
@@ -31,6 +32,9 @@
31
32
  "build:runtime": "vite build",
32
33
  "build:cli": "tsup",
33
34
  "typecheck": "tsc --noEmit",
35
+ "lint": "biome check .",
36
+ "lint:fix": "biome check --write .",
37
+ "format": "biome format --write .",
34
38
  "build:types": "tsc -p tsconfig.runtime.json",
35
39
  "build": "npm run build:runtime && npm run build:cli && npm run build:types",
36
40
  "docmedown": "node ./bin/docmedown.js",
@@ -43,7 +47,9 @@
43
47
  "build:offline": "node ./bin/docmedown.js build ./docs",
44
48
  "config:docs": "node ./bin/docmedown.js config ./docs/docs.json",
45
49
  "test": "npx tsx --test tests/parser.test.ts tests/scanner.test.ts tests/runtime-integration.test.ts tests/package-smoke.test.ts",
46
- "test:release": "npm run typecheck && npm run test && npm run build && npm run build:docs && npm pack --dry-run",
50
+ "test:release": "npm run typecheck && npm run lint && npm run test && npm run build && npm run build:docs && npm pack --dry-run",
51
+ "deploy": "node ./scripts/deploy.mjs",
52
+ "deploy:dry-run": "npm run deploy -- --dry-run",
47
53
  "prepublishOnly": "npm run test:release"
48
54
  },
49
55
  "keywords": [
@@ -85,9 +91,11 @@
85
91
  "mime-types": "^2.1.35",
86
92
  "open": "^10.1.0",
87
93
  "prompts": "^2.4.2",
88
- "ws": "^8.18.0"
94
+ "ws": "^8.18.0",
95
+ "zod": "^4.4.3"
89
96
  },
90
97
  "devDependencies": {
98
+ "@biomejs/biome": "^2.5.10",
91
99
  "@types/node": "^22.5.0",
92
100
  "@types/prismjs": "^1.26.6",
93
101
  "@types/prompts": "^2.4.9",
@@ -0,0 +1,157 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://raw.githubusercontent.com/gabrielmsilva00/docmedown/main/schemas/docs.schema.json",
4
+ "title": "DocMeDown documentation configuration",
5
+ "description": "Configuration for a DocMeDown documentation root. A directory containing docs.json is an independent documentation site.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "properties": {
9
+ "$schema": { "type": "string", "format": "uri" },
10
+ "name": { "type": "string", "minLength": 1 },
11
+ "tagline": { "type": "string" },
12
+ "description": { "type": "string" },
13
+ "version": { "type": "string" },
14
+ "rootDoc": { "type": "string", "minLength": 1 },
15
+ "source": { "$ref": "#/$defs/source" },
16
+ "theme": { "$ref": "#/$defs/theme" },
17
+ "nav": { "type": "array", "items": { "$ref": "#/$defs/navLink" } },
18
+ "socials": { "type": "array", "items": { "$ref": "#/$defs/socialLink" } },
19
+ "sidebar": { "type": "array", "items": { "$ref": "#/$defs/sidebarItem" } },
20
+ "autoIndex": { "$ref": "#/$defs/autoIndex" },
21
+ "search": { "$ref": "#/$defs/search" },
22
+ "footer": { "$ref": "#/$defs/footer" },
23
+ "componentsUrl": { "type": "string" },
24
+ "editUrl": { "type": "string" }
25
+ },
26
+ "$defs": {
27
+ "navLink": {
28
+ "type": "object",
29
+ "additionalProperties": false,
30
+ "required": ["label", "href"],
31
+ "properties": {
32
+ "label": { "type": "string", "minLength": 1 },
33
+ "href": { "type": "string", "minLength": 1 },
34
+ "external": { "type": "boolean" },
35
+ "icon": { "type": "string" }
36
+ }
37
+ },
38
+ "socialLink": {
39
+ "type": "object",
40
+ "additionalProperties": false,
41
+ "required": ["type", "url"],
42
+ "properties": {
43
+ "type": { "enum": ["github", "gitlab", "twitter", "x", "discord", "custom"] },
44
+ "url": { "type": "string", "format": "uri" },
45
+ "label": { "type": "string" },
46
+ "icon": { "type": "string" }
47
+ }
48
+ },
49
+ "source": {
50
+ "oneOf": [
51
+ {
52
+ "type": "object",
53
+ "additionalProperties": false,
54
+ "required": ["type", "repo"],
55
+ "properties": {
56
+ "type": { "const": "github" },
57
+ "repo": { "type": "string", "pattern": "^[^/\\s]+/[^/\\s]+$" },
58
+ "branch": { "type": "string", "minLength": 1 },
59
+ "docsDir": { "type": "string" },
60
+ "token": { "type": "string" },
61
+ "baseUrl": { "type": "string", "format": "uri" }
62
+ }
63
+ },
64
+ {
65
+ "type": "object",
66
+ "additionalProperties": false,
67
+ "required": ["type", "repo"],
68
+ "properties": {
69
+ "type": { "const": "gitlab" },
70
+ "repo": { "type": "string", "pattern": "^[^/\\s]+/[^/\\s]+$" },
71
+ "branch": { "type": "string", "minLength": 1 },
72
+ "docsDir": { "type": "string" },
73
+ "token": { "type": "string" },
74
+ "baseUrl": { "type": "string", "format": "uri" }
75
+ }
76
+ },
77
+ {
78
+ "type": "object",
79
+ "additionalProperties": false,
80
+ "required": ["type", "baseUrl"],
81
+ "properties": {
82
+ "type": { "const": "raw" },
83
+ "baseUrl": { "type": "string", "format": "uri" },
84
+ "branch": { "type": "string", "minLength": 1 },
85
+ "docsDir": { "type": "string" },
86
+ "token": { "type": "string" }
87
+ }
88
+ }
89
+ ]
90
+ },
91
+ "theme": {
92
+ "type": "object",
93
+ "additionalProperties": false,
94
+ "properties": {
95
+ "preset": { "enum": ["indigo", "emerald", "sunset", "violet", "rose", "slate", "cyberpunk"] },
96
+ "defaultMode": { "enum": ["light", "dark", "auto"] },
97
+ "accentColor": { "type": "string" },
98
+ "accentColorDark": { "type": "string" },
99
+ "fontFamily": { "type": "string" },
100
+ "codeTheme": { "enum": ["github", "dracula", "one-dark", "synthwave"] },
101
+ "favicon": { "type": "string" },
102
+ "logo": {
103
+ "type": "object",
104
+ "additionalProperties": false,
105
+ "properties": {
106
+ "light": { "type": "string" },
107
+ "dark": { "type": "string" },
108
+ "alt": { "type": "string" },
109
+ "text": { "type": "string" }
110
+ }
111
+ }
112
+ }
113
+ },
114
+ "autoIndex": {
115
+ "type": "object",
116
+ "additionalProperties": false,
117
+ "properties": {
118
+ "enabled": { "type": "boolean" },
119
+ "exclude": { "type": "array", "items": { "type": "string", "minLength": 1 } },
120
+ "sort": { "enum": ["alphabetical", "frontmatter", "natural"] },
121
+ "defaultCollapsed": { "type": "boolean" }
122
+ }
123
+ },
124
+ "search": {
125
+ "type": "object",
126
+ "additionalProperties": false,
127
+ "properties": {
128
+ "enabled": { "type": "boolean" },
129
+ "placeholder": { "type": "string" },
130
+ "maxResults": { "type": "integer", "minimum": 1, "maximum": 100 }
131
+ }
132
+ },
133
+ "footer": {
134
+ "type": "object",
135
+ "additionalProperties": false,
136
+ "properties": {
137
+ "copyright": { "type": "string" },
138
+ "links": { "type": "array", "items": { "$ref": "#/$defs/navLink" } },
139
+ "showBuiltWith": { "type": "boolean" }
140
+ }
141
+ },
142
+ "sidebarItem": {
143
+ "type": "object",
144
+ "additionalProperties": false,
145
+ "properties": {
146
+ "title": { "type": "string" },
147
+ "path": { "type": "string" },
148
+ "slug": { "type": "string" },
149
+ "icon": { "type": "string" },
150
+ "badge": { "type": "string" },
151
+ "badgeType": { "enum": ["info", "success", "warning", "new"] },
152
+ "collapsed": { "type": "boolean" },
153
+ "children": { "type": "array", "items": { "$ref": "#/$defs/sidebarItem" } }
154
+ }
155
+ }
156
+ }
157
+ }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "$schema": "https://raw.githubusercontent.com/gabrielmsilva00/docmedown/main/schemas/docs.schema.json",
2
3
  "name": "My Project Docs",
3
4
  "tagline": "The simplest Markdown documentation yet",
4
5
  "description": "Fast, modern documentation created with DocMeDown",