marko/docs-markdown
The canonical Marko documentation content, shipped as an installable Composer package. Every page of the Marko docs lives under this package’s docs/ directory, and MarkdownRepository reads it. This is what makes the documentation modular — the docs are a module like everything else in Marko, so search drivers and the docs site read from one source of truth instead of a copy.
Two consumers read this content:
- The search driver (
marko/docs-fts) indexes the markdown to power documentation search. - The marko.build Astro site renders it. The site’s content directory (
docs/src/content/docs) is a symlink to this package’sdocs/directory, so there is exactly one copy of every page.
Installation
Section titled “Installation”composer require marko/docs-markdownUsually installed automatically as a dependency of a search driver (marko/docs-fts).
Inject MarkdownRepository to read documentation content:
use Marko\DocsMarkdown\MarkdownRepository;
class DocsTool{ public function __construct( private MarkdownRepository $repo, ) {}
public function dump(): void { foreach ($repo->listAllPages() as $page) { echo $page; // page id, e.g. "getting-started/installation" }
$raw = $this->repo->getRawMarkdown('getting-started/installation'); }}API Reference
Section titled “API Reference”| Method | Returns | Description |
|---|---|---|
listAllPages() | list<string> | All page ids (relative paths without extension) |
getRawMarkdown(string $id) | string | Raw markdown for a page id. Throws DocsMarkdownException if the page is not found or if the resolved path falls outside the docs root (path-traversal attempt). |
getDocsPath() | string | Absolute path to the package’s docs/ root |
getRawMarkdown() uses realpath containment to verify the resolved file path stays within the docs root before reading. Any page id that resolves outside the root (e.g. ../../etc/passwd) throws DocsMarkdownException::pathTraversal() loudly.
Related Packages
Section titled “Related Packages”marko/docs— the search contractmarko/docs-fts— lexical search driver that indexes this content