@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,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>
@@ -0,0 +1,236 @@
1
+ ---
2
+ title: Writing Content
3
+ description: Learn how to write effective documentation with MDX
4
+ ---
5
+
6
+ # Writing Content
7
+
8
+ opendocs uses MDX, which combines Markdown with JSX components for rich documentation.
9
+
10
+ ## Frontmatter
11
+
12
+ Every page should start with frontmatter that defines metadata:
13
+
14
+ ```mdx
15
+ ---
16
+ title: Page Title
17
+ description: A brief description for SEO and previews
18
+ ---
19
+
20
+ # Your Content Here
21
+ ```
22
+
23
+ ### Frontmatter Fields
24
+
25
+ | Field | Required | Description |
26
+ |-------|----------|-------------|
27
+ | `title` | Yes | Page title (shown in browser tab and navigation) |
28
+ | `description` | No | Short description for SEO and social sharing |
29
+
30
+ ## Markdown Basics
31
+
32
+ opendocs supports all standard Markdown syntax.
33
+
34
+ ### Headings
35
+
36
+ ```markdown
37
+ # Heading 1
38
+ ## Heading 2
39
+ ### Heading 3
40
+ #### Heading 4
41
+ ```
42
+
43
+ <Callout type="tip">
44
+ Use `##` (H2) for main sections. These appear in the "On this page" table of contents.
45
+ </Callout>
46
+
47
+ ### Text Formatting
48
+
49
+ | Syntax | Result |
50
+ |--------|--------|
51
+ | `**bold**` | **bold** |
52
+ | `*italic*` | *italic* |
53
+ | `~~strikethrough~~` | ~~strikethrough~~ |
54
+ | `` `inline code` `` | `inline code` |
55
+
56
+ ### Lists
57
+
58
+ **Unordered lists:**
59
+
60
+ ```markdown
61
+ - First item
62
+ - Second item
63
+ - Nested item
64
+ - Another nested item
65
+ - Third item
66
+ ```
67
+
68
+ - First item
69
+ - Second item
70
+ - Nested item
71
+ - Another nested item
72
+ - Third item
73
+
74
+ **Ordered lists:**
75
+
76
+ ```markdown
77
+ 1. First step
78
+ 2. Second step
79
+ 3. Third step
80
+ ```
81
+
82
+ 1. First step
83
+ 2. Second step
84
+ 3. Third step
85
+
86
+ ### Links
87
+
88
+ ```markdown
89
+ [Link text](https://example.com)
90
+ [Internal link](/quickstart)
91
+ ```
92
+
93
+ [Link text](https://example.com) | [Internal link](/quickstart)
94
+
95
+ ### Images
96
+
97
+ Place images in the `public` directory and reference them:
98
+
99
+ ```markdown
100
+ ![Alt text](/images/screenshot.png)
101
+ ```
102
+
103
+ ### Tables
104
+
105
+ ```markdown
106
+ | Header 1 | Header 2 | Header 3 |
107
+ |----------|----------|----------|
108
+ | Cell 1 | Cell 2 | Cell 3 |
109
+ | Cell 4 | Cell 5 | Cell 6 |
110
+ ```
111
+
112
+ | Header 1 | Header 2 | Header 3 |
113
+ |----------|----------|----------|
114
+ | Cell 1 | Cell 2 | Cell 3 |
115
+ | Cell 4 | Cell 5 | Cell 6 |
116
+
117
+ ### Blockquotes
118
+
119
+ ```markdown
120
+ > This is a blockquote. Use it to highlight quotes or important notes.
121
+ ```
122
+
123
+ > This is a blockquote. Use it to highlight quotes or important notes.
124
+
125
+ ## Code Blocks
126
+
127
+ ### Basic Code Blocks
128
+
129
+ Use triple backticks with a language identifier:
130
+
131
+ ```javascript
132
+ function greet(name) {
133
+ return `Hello, ${name}!`;
134
+ }
135
+ ```
136
+
137
+ ```javascript
138
+ function greet(name) {
139
+ return `Hello, ${name}!`;
140
+ }
141
+ ```
142
+
143
+ ### Supported Languages
144
+
145
+ opendocs supports syntax highlighting for 100+ languages including:
146
+
147
+ - JavaScript, TypeScript, JSX, TSX
148
+ - Python, Ruby, Go, Rust
149
+ - HTML, CSS, SCSS
150
+ - JSON, YAML, TOML
151
+ - Bash, Shell
152
+ - SQL, GraphQL
153
+ - And many more...
154
+
155
+ ### Code Groups for Multiple Languages
156
+
157
+ Use the `CodeGroup` component to show code in multiple languages:
158
+
159
+ <CodeGroup>
160
+ ```javascript Node.js
161
+ const express = require('express');
162
+ const app = express();
163
+
164
+ app.get('/', (req, res) => {
165
+ res.send('Hello World!');
166
+ });
167
+ ```
168
+
169
+ ```python Flask
170
+ from flask import Flask
171
+ app = Flask(__name__)
172
+
173
+ @app.route('/')
174
+ def hello():
175
+ return 'Hello World!'
176
+ ```
177
+
178
+ ```go Go
179
+ package main
180
+
181
+ import "net/http"
182
+
183
+ func main() {
184
+ http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
185
+ w.Write([]byte("Hello World!"))
186
+ })
187
+ http.ListenAndServe(":8080", nil)
188
+ }
189
+ ```
190
+ </CodeGroup>
191
+
192
+ ## Using Components
193
+
194
+ Import and use built-in components directly in your MDX:
195
+
196
+ ```mdx
197
+ <Callout type="info">
198
+ This is an informational callout.
199
+ </Callout>
200
+
201
+ <CardGroup cols={2}>
202
+ <Card title="Card 1" description="Description" href="/page1" />
203
+ <Card title="Card 2" description="Description" href="/page2" />
204
+ </CardGroup>
205
+ ```
206
+
207
+ See the [Components](/components) page for all available components.
208
+
209
+ ## Best Practices
210
+
211
+ <CardGroup cols={2}>
212
+ <Card
213
+ title="Keep it concise"
214
+ description="Write short paragraphs. Use lists and tables for clarity."
215
+ icon="✂️"
216
+ />
217
+ <Card
218
+ title="Use examples"
219
+ description="Show, don't tell. Include code samples and screenshots."
220
+ icon="💻"
221
+ />
222
+ <Card
223
+ title="Structure content"
224
+ description="Use headings to create a clear hierarchy."
225
+ icon="📋"
226
+ />
227
+ <Card
228
+ title="Add callouts"
229
+ description="Highlight important info, warnings, and tips."
230
+ icon="💡"
231
+ />
232
+ </CardGroup>
233
+
234
+ <Callout type="tip">
235
+ Write documentation as if the reader is in a hurry. Get to the point quickly and make information easy to scan.
236
+ </Callout>