@opendocsdev/cli 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 (78) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +300 -0
  3. package/dist/bin/opendocs.js +712 -0
  4. package/dist/bin/opendocs.js.map +1 -0
  5. package/dist/templates/api-reference.mdx +308 -0
  6. package/dist/templates/components.mdx +286 -0
  7. package/dist/templates/configuration.mdx +190 -0
  8. package/dist/templates/docs.json +27 -0
  9. package/dist/templates/introduction.mdx +25 -0
  10. package/dist/templates/logo.svg +4 -0
  11. package/dist/templates/quickstart.mdx +59 -0
  12. package/dist/templates/writing-content.mdx +236 -0
  13. package/package.json +92 -0
  14. package/src/engine/astro.config.ts +75 -0
  15. package/src/engine/src/components/Analytics.astro +57 -0
  16. package/src/engine/src/components/ApiPlayground.astro +24 -0
  17. package/src/engine/src/components/Callout.astro +66 -0
  18. package/src/engine/src/components/Card.astro +75 -0
  19. package/src/engine/src/components/CardGroup.astro +29 -0
  20. package/src/engine/src/components/CodeGroup.astro +231 -0
  21. package/src/engine/src/components/CopyButton.astro +179 -0
  22. package/src/engine/src/components/Steps.astro +27 -0
  23. package/src/engine/src/components/Tab.astro +21 -0
  24. package/src/engine/src/components/TableOfContents.astro +119 -0
  25. package/src/engine/src/components/Tabs.astro +135 -0
  26. package/src/engine/src/components/index.ts +107 -0
  27. package/src/engine/src/components/react/ApiPlayground/AuthSection.tsx +91 -0
  28. package/src/engine/src/components/react/ApiPlayground/CodeBlock.tsx +66 -0
  29. package/src/engine/src/components/react/ApiPlayground/CodeSnippets.tsx +66 -0
  30. package/src/engine/src/components/react/ApiPlayground/CollapsibleSection.tsx +26 -0
  31. package/src/engine/src/components/react/ApiPlayground/KeyValueEditor.tsx +58 -0
  32. package/src/engine/src/components/react/ApiPlayground/ResponseDisplay.tsx +109 -0
  33. package/src/engine/src/components/react/ApiPlayground/Spinner.tsx +6 -0
  34. package/src/engine/src/components/react/ApiPlayground/constants.ts +16 -0
  35. package/src/engine/src/components/react/ApiPlayground/generators.test.ts +130 -0
  36. package/src/engine/src/components/react/ApiPlayground/generators.ts +75 -0
  37. package/src/engine/src/components/react/ApiPlayground/index.tsx +490 -0
  38. package/src/engine/src/components/react/ApiPlayground/types.ts +35 -0
  39. package/src/engine/src/components/react/Callout.tsx +54 -0
  40. package/src/engine/src/components/react/Card.tsx +48 -0
  41. package/src/engine/src/components/react/CardGroup.tsx +24 -0
  42. package/src/engine/src/components/react/FeedbackWidget.tsx +166 -0
  43. package/src/engine/src/components/react/GitHubLink.tsx +28 -0
  44. package/src/engine/src/components/react/NavigationCard.tsx +53 -0
  45. package/src/engine/src/components/react/PageActions.tsx +124 -0
  46. package/src/engine/src/components/react/PageFooter.tsx +91 -0
  47. package/src/engine/src/components/react/SearchModal.tsx +358 -0
  48. package/src/engine/src/components/react/SearchProvider.tsx +37 -0
  49. package/src/engine/src/components/react/Sidebar.tsx +369 -0
  50. package/src/engine/src/components/react/SidebarSearchTrigger.tsx +57 -0
  51. package/src/engine/src/components/react/Steps.tsx +25 -0
  52. package/src/engine/src/components/react/ThemeToggle.tsx +72 -0
  53. package/src/engine/src/components/react/index.ts +14 -0
  54. package/src/engine/src/env.d.ts +10 -0
  55. package/src/engine/src/layouts/DocsLayout.astro +357 -0
  56. package/src/engine/src/lib/__tests__/markdown.test.ts +124 -0
  57. package/src/engine/src/lib/__tests__/mdx-loader.test.ts +205 -0
  58. package/src/engine/src/lib/config.ts +79 -0
  59. package/src/engine/src/lib/markdown.ts +54 -0
  60. package/src/engine/src/lib/mdx-loader.ts +143 -0
  61. package/src/engine/src/lib/mdx-utils.ts +72 -0
  62. package/src/engine/src/lib/remark-opendocs.ts +195 -0
  63. package/src/engine/src/lib/utils.ts +221 -0
  64. package/src/engine/src/pages/[...slug].astro +115 -0
  65. package/src/engine/src/pages/index.astro +71 -0
  66. package/src/engine/src/scripts/mobile-sidebar.ts +56 -0
  67. package/src/engine/src/scripts/theme-init.ts +25 -0
  68. package/src/engine/src/styles/global.css +703 -0
  69. package/src/engine/tailwind.config.mjs +60 -0
  70. package/src/engine/tsconfig.json +15 -0
  71. package/src/templates/api-reference.mdx +308 -0
  72. package/src/templates/components.mdx +286 -0
  73. package/src/templates/configuration.mdx +190 -0
  74. package/src/templates/docs.json +27 -0
  75. package/src/templates/introduction.mdx +25 -0
  76. package/src/templates/logo.svg +4 -0
  77. package/src/templates/quickstart.mdx +59 -0
  78. package/src/templates/writing-content.mdx +236 -0
@@ -0,0 +1,286 @@
1
+ ---
2
+ title: Components
3
+ description: Built-in MDX components to enhance your documentation
4
+ ---
5
+
6
+ # Components
7
+
8
+ opendocs includes several built-in components to create rich, interactive documentation.
9
+
10
+ ## Callout
11
+
12
+ Use callouts to highlight important information, warnings, tips, or errors.
13
+
14
+ <Callout type="info">
15
+
16
+ This is an **info** callout. Use it for general information and notes.
17
+
18
+ </Callout>
19
+
20
+ <Callout type="tip">
21
+
22
+ This is a **tip** callout. Use it for helpful suggestions and best practices.
23
+
24
+ </Callout>
25
+
26
+ <Callout type="warning">
27
+
28
+ This is a **warning** callout. Use it to caution readers about potential issues.
29
+
30
+ </Callout>
31
+
32
+ <Callout type="error">
33
+
34
+ This is an **error** callout. Use it for critical information or common mistakes.
35
+
36
+ </Callout>
37
+
38
+ ```mdx
39
+ <Callout type="info">
40
+ Your message here. Supports **markdown** formatting.
41
+ </Callout>
42
+ ```
43
+
44
+ ### Callout Types
45
+
46
+ | Type | Usage |
47
+ |------|-------|
48
+ | `info` | General information (default) |
49
+ | `tip` | Helpful suggestions |
50
+ | `warning` | Cautions and potential issues |
51
+ | `error` | Critical warnings or common mistakes |
52
+
53
+ ## Code Groups
54
+
55
+ Display code examples in multiple languages or package managers with tabs.
56
+
57
+ <CodeGroup>
58
+ ```javascript JavaScript
59
+ const greeting = "Hello, World!";
60
+ console.log(greeting);
61
+ ```
62
+
63
+ ```python Python
64
+ greeting = "Hello, World!"
65
+ print(greeting)
66
+ ```
67
+
68
+ ```rust Rust
69
+ fn main() {
70
+ println!("Hello, World!");
71
+ }
72
+ ```
73
+ </CodeGroup>
74
+
75
+ ````mdx
76
+ <CodeGroup>
77
+ ```javascript JavaScript
78
+ const greeting = "Hello, World!";
79
+ ```
80
+
81
+ ```python Python
82
+ greeting = "Hello, World!"
83
+ ```
84
+ </CodeGroup>
85
+ ````
86
+
87
+ ## Cards
88
+
89
+ Use cards to create navigation links or highlight features.
90
+
91
+ <CardGroup cols={2}>
92
+ <Card title="Getting Started" description="Learn the basics of opendocs" href="/quickstart" icon="🚀" />
93
+ <Card title="Configuration" description="Customize your documentation site" href="/configuration" icon="⚙️" />
94
+ <Card title="Components" description="Explore built-in MDX components" href="/components" icon="🧩" />
95
+ <Card title="Writing Content" description="Learn how to write effective docs" href="/writing-content" icon="✍️" />
96
+ </CardGroup>
97
+
98
+ ```mdx
99
+ <CardGroup cols={2}>
100
+ <Card
101
+ title="Getting Started"
102
+ description="Learn the basics"
103
+ href="/quickstart"
104
+ icon="🚀"
105
+ />
106
+ <Card
107
+ title="Configuration"
108
+ description="Customize your site"
109
+ href="/configuration"
110
+ icon="⚙️"
111
+ />
112
+ </CardGroup>
113
+ ```
114
+
115
+ ### Card Props
116
+
117
+ | Prop | Type | Description |
118
+ |------|------|-------------|
119
+ | `title` | string | Card title (required) |
120
+ | `description` | string | Short description |
121
+ | `href` | string | Link destination |
122
+ | `icon` | string | Emoji or icon character |
123
+
124
+ ### CardGroup Props
125
+
126
+ | Prop | Type | Default | Description |
127
+ |------|------|---------|-------------|
128
+ | `cols` | 1, 2, 3, 4 | 2 | Number of columns |
129
+
130
+ ## Steps
131
+
132
+ Create numbered step-by-step instructions.
133
+
134
+ <Steps>
135
+
136
+ ### Install the CLI
137
+
138
+ Install opendocs globally using npm, yarn, or pnpm.
139
+
140
+ ### Initialize your project
141
+
142
+ Run `opendocs init my-docs` to create a new documentation project.
143
+
144
+ ### Start the dev server
145
+
146
+ Run `opendocs dev` to preview your documentation locally.
147
+
148
+ ### Deploy
149
+
150
+ Build and deploy your documentation to any static hosting service.
151
+
152
+ </Steps>
153
+
154
+ ```mdx
155
+ <Steps>
156
+
157
+ ### Step One
158
+
159
+ Description for step one.
160
+
161
+ ### Step Two
162
+
163
+ Description for step two.
164
+
165
+ ### Step Three
166
+
167
+ Description for step three.
168
+
169
+ </Steps>
170
+ ```
171
+
172
+ <Callout type="tip">
173
+
174
+ Steps automatically number each child heading (h3, h4, etc.) and display them with a connected timeline.
175
+
176
+ </Callout>
177
+
178
+ ## Combining Components
179
+
180
+ Components can be nested and combined for more complex layouts.
181
+
182
+ ### Steps with Cards
183
+
184
+ Use Cards inside Steps to provide navigation options at each stage:
185
+
186
+ <Steps>
187
+
188
+ ### Choose your setup
189
+
190
+ <CardGroup cols={2}>
191
+ <Card title="Quick Start" description="Get running in minutes" href="/quickstart" icon="⚡" />
192
+ <Card title="Manual Setup" description="Full control over configuration" href="/configuration" icon="🔧" />
193
+ </CardGroup>
194
+
195
+ ### Configure your project
196
+
197
+ <Callout type="info">
198
+
199
+ Edit `docs.json` to customize navigation, theme, and features.
200
+
201
+ </Callout>
202
+
203
+ ### Write your content
204
+
205
+ Create `.mdx` files and start documenting your project.
206
+
207
+ </Steps>
208
+
209
+ ### Cards with Code Examples
210
+
211
+ Combine explanatory cards with code samples:
212
+
213
+ <CardGroup cols={2}>
214
+ <Card title="Frontend" description="React, Vue, or vanilla JS" icon="🖥️" />
215
+ <Card title="Backend" description="Node.js, Python, or Go" icon="⚙️" />
216
+ </CardGroup>
217
+
218
+ <CodeGroup>
219
+ ```javascript React
220
+ import { useState } from 'react';
221
+
222
+ function App() {
223
+ const [count, setCount] = useState(0);
224
+ return <button onClick={() => setCount(count + 1)}>{count}</button>;
225
+ }
226
+ ```
227
+
228
+ ```python FastAPI
229
+ from fastapi import FastAPI
230
+
231
+ app = FastAPI()
232
+
233
+ @app.get("/")
234
+ def read_root():
235
+ return {"Hello": "World"}
236
+ ```
237
+ </CodeGroup>
238
+
239
+ ### Callouts in Context
240
+
241
+ Use callouts within other components to highlight important information:
242
+
243
+ <Steps>
244
+
245
+ ### Install dependencies
246
+
247
+ ```bash
248
+ pnpm install
249
+ ```
250
+
251
+ <Callout type="warning">
252
+
253
+ Make sure you have Node.js 18+ installed before proceeding.
254
+
255
+ </Callout>
256
+
257
+ ### Start development
258
+
259
+ ```bash
260
+ pnpm dev
261
+ ```
262
+
263
+ <Callout type="tip">
264
+
265
+ The dev server supports hot reload - changes appear instantly!
266
+
267
+ </Callout>
268
+
269
+ </Steps>
270
+
271
+ ### Feature Comparison Tables
272
+
273
+ Combine tables with callouts for feature documentation:
274
+
275
+ | Feature | Free | Pro | Enterprise |
276
+ |---------|------|-----|------------|
277
+ | Pages | 10 | 100 | Unlimited |
278
+ | Custom domain | No | Yes | Yes |
279
+ | Analytics | Basic | Advanced | Advanced |
280
+ | Support | Community | Email | Dedicated |
281
+
282
+ <Callout type="info">
283
+
284
+ All plans include search, dark mode, and responsive design.
285
+
286
+ </Callout>
@@ -0,0 +1,190 @@
1
+ ---
2
+ title: Configuration
3
+ description: Configure your documentation site with docs.json
4
+ ---
5
+
6
+ # Configuration
7
+
8
+ All configuration for your opendocs site lives in a single `docs.json` file at the root of your project.
9
+
10
+ ## Basic Configuration
11
+
12
+ Here's a minimal configuration to get started:
13
+
14
+ ```json
15
+ {
16
+ "name": "My Documentation",
17
+ "logo": "/logo.svg",
18
+ "navigation": [
19
+ {
20
+ "group": "Getting Started",
21
+ "pages": ["introduction", "quickstart"]
22
+ }
23
+ ]
24
+ }
25
+ ```
26
+
27
+ ## Full Configuration Reference
28
+
29
+ ```json
30
+ {
31
+ "name": "My Documentation",
32
+ "logo": "/logo.svg",
33
+ "favicon": "/favicon.ico",
34
+ "navigation": [
35
+ {
36
+ "group": "Getting Started",
37
+ "pages": ["introduction", "quickstart"]
38
+ },
39
+ {
40
+ "group": "Guides",
41
+ "pages": ["components", "configuration", "writing-content"]
42
+ },
43
+ {
44
+ "group": "API",
45
+ "pages": ["api-reference"]
46
+ }
47
+ ],
48
+ "theme": {
49
+ "primaryColor": "#0066cc",
50
+ "darkMode": true
51
+ },
52
+ "features": {
53
+ "search": true,
54
+ "feedback": false,
55
+ "analytics": false
56
+ }
57
+ }
58
+ ```
59
+
60
+ ## Configuration Options
61
+
62
+ ### name
63
+
64
+ The name of your documentation site. Displayed in the header and browser tab.
65
+
66
+ ```json
67
+ {
68
+ "name": "Acme Documentation"
69
+ }
70
+ ```
71
+
72
+ ### logo
73
+
74
+ Path to your logo image. Place the file in the `public` directory.
75
+
76
+ ```json
77
+ {
78
+ "logo": "/logo.svg"
79
+ }
80
+ ```
81
+
82
+ <Callout type="tip">
83
+ SVG logos are recommended as they scale well and support dark mode.
84
+ </Callout>
85
+
86
+ ### favicon
87
+
88
+ Path to your favicon. Defaults to the logo if not specified.
89
+
90
+ ```json
91
+ {
92
+ "favicon": "/favicon.ico"
93
+ }
94
+ ```
95
+
96
+ ### navigation
97
+
98
+ Define the sidebar navigation structure. Organize pages into groups.
99
+
100
+ ```json
101
+ {
102
+ "navigation": [
103
+ {
104
+ "group": "Getting Started",
105
+ "pages": ["introduction", "quickstart"]
106
+ },
107
+ {
108
+ "group": "API Reference",
109
+ "pages": ["api/authentication", "api/endpoints"]
110
+ }
111
+ ]
112
+ }
113
+ ```
114
+
115
+ <Callout type="info">
116
+ Page paths are relative to the project root. A page `api/authentication` maps to `api/authentication.mdx`.
117
+ </Callout>
118
+
119
+ ### theme
120
+
121
+ Customize the visual appearance of your documentation.
122
+
123
+ ```json
124
+ {
125
+ "theme": {
126
+ "primaryColor": "#0066cc",
127
+ "darkMode": true
128
+ }
129
+ }
130
+ ```
131
+
132
+ | Option | Type | Default | Description |
133
+ |--------|------|---------|-------------|
134
+ | `primaryColor` | string | `#0066cc` | Primary brand color for links, buttons, etc. |
135
+ | `darkMode` | boolean | `true` | Enable dark mode toggle |
136
+
137
+ ### features
138
+
139
+ Enable or disable built-in features.
140
+
141
+ ```json
142
+ {
143
+ "features": {
144
+ "search": true,
145
+ "feedback": false,
146
+ "analytics": false
147
+ }
148
+ }
149
+ ```
150
+
151
+ | Feature | Type | Default | Description |
152
+ |---------|------|---------|-------------|
153
+ | `search` | boolean | `true` | Enable full-text search (powered by Pagefind) |
154
+ | `feedback` | boolean | `false` | Show "Was this helpful?" feedback widget |
155
+ | `analytics` | boolean | `false` | Enable page view analytics |
156
+
157
+ ## File Structure
158
+
159
+ A typical opendocs project structure:
160
+
161
+ ```
162
+ my-docs/
163
+ ├── docs.json # Configuration file
164
+ ├── introduction.mdx # Documentation pages
165
+ ├── quickstart.mdx
166
+ ├── guides/
167
+ │ ├── components.mdx
168
+ │ └── configuration.mdx
169
+ ├── api/
170
+ │ └── reference.mdx
171
+ └── public/
172
+ ├── logo.svg # Static assets
173
+ └── favicon.ico
174
+ ```
175
+
176
+ <Callout type="warning">
177
+ Page files must have the `.mdx` extension. Regular `.md` files are not supported.
178
+ </Callout>
179
+
180
+ ## Environment Variables
181
+
182
+ opendocs supports the following environment variables:
183
+
184
+ | Variable | Description |
185
+ |----------|-------------|
186
+ | `PORT` | Development server port (default: 4321) |
187
+
188
+ ```bash
189
+ PORT=3000 opendocs dev
190
+ ```
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "{{PROJECT_NAME}}",
3
+ "logo": "/logo.svg",
4
+ "navigation": [
5
+ {
6
+ "group": "Getting Started",
7
+ "pages": ["introduction", "quickstart"]
8
+ },
9
+ {
10
+ "group": "Guides",
11
+ "pages": ["components", "configuration", "writing-content"]
12
+ },
13
+ {
14
+ "group": "API",
15
+ "pages": ["api-reference"]
16
+ }
17
+ ],
18
+ "theme": {
19
+ "primaryColor": "#0066cc",
20
+ "darkMode": true
21
+ },
22
+ "features": {
23
+ "search": true,
24
+ "feedback": false,
25
+ "analytics": false
26
+ }
27
+ }
@@ -0,0 +1,25 @@
1
+ ---
2
+ title: Introduction
3
+ description: Welcome to the documentation
4
+ ---
5
+
6
+ # Introduction
7
+
8
+ Welcome to your new documentation site! This is built with **opendocs**, an open-source Mintlify alternative.
9
+
10
+ <Callout type="info">
11
+ This is an example callout. You can use callouts to highlight important information.
12
+ </Callout>
13
+
14
+ ## What is opendocs?
15
+
16
+ opendocs is a modern documentation generator that allows you to write beautiful docs with zero configuration. Features include:
17
+
18
+ - **MDX Support** - Write content in Markdown with JSX components
19
+ - **Full-text Search** - Built-in search powered by Pagefind
20
+ - **Dark Mode** - Automatic dark mode support
21
+ - **Analytics & Feedback** - Track pageviews and collect reader feedback
22
+
23
+ ## Next Steps
24
+
25
+ Check out the [Quickstart](/quickstart) guide to get started with your documentation.
@@ -0,0 +1,4 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="40" height="40">
2
+ <rect width="100" height="100" rx="20" fill="#0066cc"/>
3
+ <text x="50" y="65" font-family="system-ui, sans-serif" font-size="40" font-weight="bold" fill="white" text-anchor="middle">D</text>
4
+ </svg>
@@ -0,0 +1,59 @@
1
+ ---
2
+ title: Quickstart
3
+ description: Get started with opendocs in minutes
4
+ ---
5
+
6
+ # Quickstart
7
+
8
+ Follow these steps to get your documentation site up and running.
9
+
10
+ ## Installation
11
+
12
+ Install the opendocs CLI globally using your preferred package manager:
13
+
14
+ <CodeGroup>
15
+ ```bash npm
16
+ npm install -g @opendocsdev/cli
17
+ ```
18
+
19
+ ```bash yarn
20
+ yarn global add @opendocsdev/cli
21
+ ```
22
+
23
+ ```bash pnpm
24
+ pnpm add -g @opendocsdev/cli
25
+ ```
26
+ </CodeGroup>
27
+
28
+ ## Create a New Project
29
+
30
+ Initialize a new documentation project:
31
+
32
+ ```bash
33
+ opendocs init my-docs
34
+ cd my-docs
35
+ ```
36
+
37
+ ## Start the Development Server
38
+
39
+ Run the development server with hot reload:
40
+
41
+ ```bash
42
+ opendocs dev
43
+ ```
44
+
45
+ Your documentation site is now running at `http://localhost:4321`.
46
+
47
+ ## Build for Production
48
+
49
+ When you're ready to deploy, build your site:
50
+
51
+ ```bash
52
+ opendocs build
53
+ ```
54
+
55
+ This creates an optimized build in the `dist` folder, ready for deployment to any static hosting service.
56
+
57
+ <Callout type="tip">
58
+ You can preview the production build locally by running `opendocs preview`.
59
+ </Callout>