Skip to content

Commit 3674b5d

Browse files
committed
docs
1 parent ded7470 commit 3674b5d

12 files changed

Lines changed: 286 additions & 305 deletions

File tree

md/architecture.md

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,24 @@
11
# Architecture
22

3-
## Current pipeline
3+
## Build pipeline
44

5-
The current implementation is intentionally small.
5+
1. `Docsmith` exposes the static and fluent API.
6+
2. `Builder` collects configuration: versions, hub entries, LLM export, theme, Open Graph, and more.
7+
3. `BuildConfig` validates the source and output paths.
8+
4. `SourceScanner` discovers Markdown files and reads frontmatter. Versioned builds scan one source directory per version.
9+
5. `CommonMarkRenderer` converts Markdown to HTML through League CommonMark with GitHub-flavored Markdown extensions.
10+
6. `SiteBuilder` renders pages with sidebar navigation, version pills, and the hub dropdown, and writes them to the output directory.
11+
7. `AssetPublisher` publishes CSS and JS assets and generates `search-index.json`, `sitemap.xml`, `.nojekyll`, and the LLM export files.
612

7-
1. `Docsmith` exposes the public API.
8-
2. `Builder` collects configuration (versions, llms-export, readme-index, theme, etc.).
9-
3. `BuildConfig` validates source and output paths.
10-
4. `SourceScanner` discovers Markdown files (respects per-version source directories).
11-
5. `CommonMarkRenderer` converts Markdown into HTML.
12-
6. `SiteBuilder` writes HTML pages, hub dropdown and version pills, search overlay, and publishes CSS/JS assets.
13-
7. `AssetPublisher` generates `search-index.json`, `sitemap.xml`, `.nojekyll`, `llms.txt`, `llms-full.txt`, and `export/docs.md`.
13+
Remote source syncing lives in `src/RemoteSources/` and runs before a build. It only writes local directories; the pipeline above never talks to the network.
1414

15-
## Current source model
15+
## Document model
1616

17-
Every discovered Markdown file is normalized into a `Document` object containing:
17+
Every discovered Markdown file becomes a `Document` object containing:
1818

1919
- source path
2020
- relative path
2121
- output path
2222
- title
2323
- raw Markdown
2424
- rendered HTML
25-
26-
## Current renderer
27-
28-
The current renderer produces:
29-
30-
- a sidebar navigation
31-
- a main content area
32-
- a generated landing page when needed
33-
- local CSS under `assets/app.css`
34-
35-
This is the minimal implementation baseline, not the final architecture.

md/development.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
## Quality commands
44

55
```bash
6-
composer test:lint
7-
composer test:types
8-
composer test:unit
9-
composer test
6+
composer test:lint # rector --dry-run && pint --test
7+
composer test:types # phpstan
8+
composer test:unit # pest --parallel
9+
composer test # all of the above
1010
```
1111

1212
## Tooling
@@ -28,7 +28,7 @@ That command uses Docsmith itself to read Markdown from `md/` and regenerate the
2828

2929
## CI / GitHub Actions
3030

31-
The repository includes a workflow at `.github/workflows/docs.yml` that builds and commits `docs/` on every push that changes the source markdown or build script.
31+
The repository includes a workflow at `.github/workflows/docs.yml` that builds and commits `docs/` on every push that changes the source Markdown or the build script.
3232

3333
If you enable generated Open Graph images, install Node, Playwright, and Chromium in CI as well:
3434

@@ -85,4 +85,4 @@ jobs:
8585
fi
8686
```
8787
88-
Adjust the PHP version, source paths, and build command to match your project. Without Open Graph capture you can omit the Node/Playwright steps.
88+
Adjust the PHP version, source paths, and build command to match your project. Without Open Graph capture you can omit the Node and Playwright steps.

md/docs-hub.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Docs Hub
22

3-
The docs hub builds several **independent** documentation sets into one site. A dropdown in the sidebar switches between them.
3+
The docs hub builds several independent documentation sets into one site. A dropdown in the sidebar switches between them.
44

55
## Setup
66

7-
Pass one entry per documentation set to `->hub()`:
7+
Pass one entry per documentation set to `hub()`:
88

99
```php
1010
use Docsmith\Docsmith;
@@ -21,13 +21,13 @@ Docsmith::make()
2121

2222
## How it works
2323

24-
- Each entry gets one dropdown option and mounts under its slug (`/package-a/`, `/package-b/`).
25-
- Nothing is generated at the root: `/` simply forwards to the first entry.
24+
- Each entry gets one dropdown option and mounts under its slug (`/package-a/...`, `/package-b/...`).
25+
- Nothing is generated at the root. `/` forwards to the first entry.
2626
- Frontmatter `order:` still applies per page.
2727

2828
## Navigation order
2929

30-
Set `navigation` on an entry to control its sidebar order. Entries are matched by title, sidebar label, or file path; pages not listed keep their natural order after the listed ones.
30+
Set `navigation` on an entry to control its sidebar order. Entries are matched by title, sidebar label, or file path. Pages not listed keep their natural order after the listed ones:
3131

3232
```php
3333
->hub([
@@ -40,18 +40,18 @@ Set `navigation` on an entry to control its sidebar order. Entries are matched b
4040
])
4141
```
4242

43-
Entries without `navigation` fall back to the global `->navigationOrder([...])`.
43+
Entries without `navigation` fall back to the global `navigationOrder([...])`.
4444

4545
## Hub entries with versions
4646

47-
An entry can embed a `versions` list. The entry stays a **single** dropdown item, and its pages get version pill buttons:
47+
An entry can embed a `versions` list. The entry stays a single dropdown item, and its pages get version pill buttons:
4848

4949
```php
5050
->hub([
5151
'auth-jobs' => [
5252
'label' => 'Auth Jobs',
5353
'source' => __DIR__ . '/md/auth-jobs', // backs the default version
54-
'navigation' => ['index.md', 'usage.md', ...], // optional, per entry
54+
'navigation' => ['index.md', 'usage.md'], // optional, per entry
5555
'versions' => [
5656
['slug' => 'v2', 'label' => 'v2', 'default' => true],
5757
['slug' => 'v1', 'label' => 'v1', 'source' => __DIR__ . '/md/auth-jobs-1x'],
@@ -61,7 +61,7 @@ An entry can embed a `versions` list. The entry stays a **single** dropdown item
6161
```
6262

6363
- The `versions` list describes all versions of that entry.
64-
- The primary version flagged `default`, else the first listedmounts at the entry root (`/auth-jobs/`); siblings nest under it (`/auth-jobs/v1/`).
65-
- The entry-level `source` may stand in for the primary version's source (as above). Other versions need their own `source`, or resolve to `{source}/{entry-slug}/{version-slug}` when `->source()` is set.
64+
- The primary version (flagged `default`, otherwise the first listed) mounts at the entry root (`/auth-jobs/...`). Siblings nest under it (`/auth-jobs/v1/...`).
65+
- The entry-level `source` can stand in for the primary version's source, as above. Other versions need their own `source`, or they resolve to `{source}/{entry-slug}/{version-slug}` when `source()` is set.
6666

67-
So in the built site the dropdown shows only "Auth Jobs"never "Auth Jobs v1" while Auth Jobs pages carry v1/v2 pills.
67+
In the built site the dropdown shows only "Auth Jobs", never "Auth Jobs v1", while Auth Jobs pages carry v1/v2 pills.

md/index.md

Lines changed: 58 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,60 @@
11
# Docsmith
22

3-
Docsmith is a small PHP package for turning Markdown files into a static documentation site.
4-
5-
## Current capabilities
6-
7-
- Build a multi-page documentation site from a Markdown directory.
8-
- Generate one HTML page per Markdown file.
9-
- Publish local CSS assets into the output directory.
10-
- Publish local JS assets for search, theme toggle, and code-copy UX.
11-
- Support both a static entry point and a fluent builder API.
12-
- Build sites from the command line via the bundled `bin/docsmith` binary.
13-
- Render Markdown through League CommonMark with GitHub-flavored extensions.
14-
- Parse frontmatter metadata (`title`, `description`, `slug`, `order`, `sidebar_label`, `hidden`).
15-
- Hide pages from navigation, search, and pagination via frontmatter `hidden: true`.
16-
- Generate `search-index.json`, `sitemap.xml`, and `.nojekyll`.
17-
- Support repository/edit links and previous/next page navigation.
18-
- Build multiple versions of one documentation set with pill buttons on every page.
19-
- Assemble a docs hub of independent documentation sets with a sidebar dropdown.
20-
- Sync Markdown from remote Git repositories via smart HTTPS (no git binary, no clones).
21-
- Search overlay with `Cmd+K` / `Ctrl+K` keyboard shortcut.
22-
- AI-consumable export: `llms.txt`, `llms-full.txt`, `export/docs.md`.
23-
- Open Graph / Twitter card tags and generated social preview images.
24-
- Sidebar "Built with DocSmith" attribution that can be disabled per build.
25-
- Validate the package with Pest, PHPStan, Rector, and Pint.
26-
27-
## Current status
28-
29-
Docsmith is actively used to generate documentation for multiple packages and supports static-hosting workflows out of the box.
30-
31-
Search includes both:
32-
33-
- sidebar link filtering
34-
- global index search powered by generated `search-index.json`
35-
- overlay modal with keyboard shortcut
36-
37-
## Documentation pages
38-
39-
- Installation
40-
- Usage
41-
- Architecture
42-
- Development
43-
- Versioned Docs
44-
- Docs Hub
45-
- Remote Sources
46-
- Workflows
47-
- LLM Export
48-
- Open Graph
3+
Docsmith is a PHP package that turns a directory of Markdown files into a static documentation site.
4+
5+
## Features
6+
7+
- Builds one HTML page per Markdown file into a self-contained output directory.
8+
- Sidebar navigation with grouping, active page highlighting, and a filter box.
9+
- Global search backed by a generated `search-index.json`, plus a `Cmd+K` / `Ctrl+K` search overlay.
10+
- Dark mode, syntax-highlighted code blocks, and a copy button on snippets.
11+
- Frontmatter support for `title`, `description`, `slug`, `order`, `sidebar_label`, and `hidden`.
12+
- Versioned docs with pill buttons to switch versions.
13+
- Docs hub that combines several independent documentation sets under one sidebar dropdown.
14+
- Remote source syncing that pulls Markdown from any Git host over plain HTTPS, no `git` binary needed.
15+
- Generated `search-index.json`, `sitemap.xml`, `.nojekyll`, and favicon on every build.
16+
- Text exports for LLMs: `llms.txt`, `llms-full.txt`, and `export/docs.md`.
17+
- Open Graph and Twitter card tags with optional generated preview images.
18+
- Edit links, previous/next navigation, and a right sidebar table of contents.
19+
- Three ways to run it: a static API, a fluent builder, and a `vendor/bin/docsmith` CLI.
20+
21+
## Requirements
22+
23+
- PHP 8.3 or newer
24+
- Composer
25+
26+
No framework is required. Docsmith has no Laravel or Illuminate dependency.
27+
28+
## Quick start
29+
30+
```bash
31+
composer require --dev mrpunyapal/docsmith
32+
```
33+
34+
```php
35+
use Docsmith\Docsmith;
36+
37+
Docsmith::build(
38+
source: __DIR__ . '/md',
39+
title: 'Project Docs',
40+
);
41+
```
42+
43+
This reads Markdown from `md/` and writes the site to `docs/` by default, which works directly with GitHub Pages.
44+
45+
## Documentation
46+
47+
- [Installation](installation.md)
48+
- [Usage](usage.md)
49+
- [Versioned Docs](versioned-docs.md)
50+
- [Docs Hub](docs-hub.md)
51+
- [Remote Sources](remote-sources.md)
52+
- [Workflows](workflows.md)
53+
- [LLM Export](llm-export.md)
54+
- [Open Graph Images](open-graph.md)
55+
- [Architecture](architecture.md)
56+
- [Development](development.md)
57+
58+
## License
59+
60+
MIT. See [LICENSE](https://github.com/MrPunyapal/docsmith/blob/main/LICENSE) for details.

md/installation.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
## Install the package
99

1010
```bash
11-
composer require mrpunyapal/docsmith
11+
composer require --dev mrpunyapal/docsmith
1212
```
1313

1414
## Install the AI agent skill
1515

16-
Docsmith ships an [Agent Skills](https://agentskills.io)-compatible skill (`docsmith-development`) that teaches AI agents Claude Code, Cursor, Codex, OpenCode, and others — how to use the package correctly: build options, frontmatter keys, versioned docs, docs hubs, and remote source syncing.
16+
Docsmith ships an [Agent Skills](https://agentskills.io) compatible skill called `docsmith-development`. It teaches coding agents such as Claude Code, Cursor, Codex, and OpenCode how to use the package: build options, frontmatter keys, versioned docs, docs hubs, and remote source syncing.
1717

1818
### Via Laravel Boost
1919

@@ -23,7 +23,7 @@ If your Laravel project uses [Boost](https://laravel.com/docs/boost), the skill
2323
php artisan boost:install
2424
```
2525

26-
You can also fetch it directly from this repository:
26+
You can also add it directly from this repository:
2727

2828
```bash
2929
php artisan boost:add-skill MrPunyapal/docsmith/resources/boost/skills
@@ -37,11 +37,11 @@ Any agent supported by the [skills CLI](https://skills.sh) can install it too:
3737
npx skills add MrPunyapal/docsmith/resources/boost/skills
3838
```
3939

40-
After installing, ask your agent to activate the `docsmith-development` skill when working on documentation builds.
40+
After installing, ask your agent to activate the `docsmith-development` skill when it works on documentation builds.
4141

4242
## Build documentation
4343

44-
Docsmith can build a static site from any Markdown directory, either from PHP or from the command line.
44+
Docsmith builds a static site from any Markdown directory, either from PHP or from the command line.
4545

4646
### Command line
4747

@@ -66,4 +66,4 @@ Docsmith::build(
6666
);
6767
```
6868

69-
That setup keeps the Markdown source in `md/` and writes the generated site into `docs/`. The main entry page is written to `docs/index.html`.
69+
This setup keeps the Markdown source in `md/` and writes the generated site into `docs/`. The entry page is written to `docs/index.html`.

md/llm-export.md

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# LLM Export
22

3-
Docsmith can generate AI-consumable exports of your documentation for use with LLMs and AI agents.
3+
Docsmith can export your documentation as plain text files for use with LLMs and AI agents.
44

55
## Enabling the export
66

7-
Export is **enabled by default**. Disable it with:
7+
The export is enabled by default. To turn it off, pass `false`:
88

99
```php
1010
Docsmith::make()
@@ -36,7 +36,7 @@ A directory listing per the [llms.txt](https://llmstxt.org/) standard:
3636

3737
### `llms-full.txt`
3838

39-
Every page rendered as plain text, concatenated:
39+
Every page rendered as plain text and concatenated:
4040

4141
```
4242
# Installation
@@ -52,20 +52,10 @@ Set environment variables...
5252

5353
### `export/docs.md`
5454

55-
Every page's raw Markdown merged into a single file with frontmatter metadata:
56-
57-
```
58-
# Installation
59-
60-
> Install the package with composer...
61-
62-
## Requirements
63-
64-
...
65-
```
55+
Every page's raw Markdown merged into a single file with frontmatter metadata.
6656

6757
## Requirements
6858

6959
`siteUrl` must be set for correct URL generation in `llms.txt`.
7060

71-
If no `index.md` exists in the source directory, a generated landing page is included in the export.
61+
If no `index.md` exists in the source directory, the generated landing page is included in the export.

0 commit comments

Comments
 (0)