Contents

API

The DocumentationRenderer class is part of Uchū Docs namespace and provides core logic for rendering and managing Markdown-based documentation.


Diagram

_MERMAID_BLOCK83e797659734a4cae585d6c4a873df62

Constructor

__construct(string $docsDirectory, ?PluginManager $pluginManager = null, string $basePath = '', ?string $contentDirectory = null)

Initializes the renderer.

Public Methods

getAvailablePages

getAvailablePages(): array

Returns a hierarchical array of available pages with unique identifiers.

renderPagesHierarchy

renderPagesHierarchy(array $hierarchy, int $depth = 0): string

Renders the documentation structure as an HTML menu.

renderPage

renderPage(string $pageIdentifier): string

Renders a single documentation page from Markdown to HTML.

getMarkdownFiles

getMarkdownFiles(): array

Recursively fetches all .md files in the content directory.

findMarkdownFileByIdentifier

findMarkdownFileByIdentifier(string $identifier): string

Finds a Markdown file by its identifier. Searches the content and docs directories.

findMarkdownFile

findMarkdownFile(string $pageName): string

Tries to locate a Markdown file by its name (or path-like identifier).

getPageTitle

getPageTitle(string $filePath): string

Extracts the first Markdown heading from a file to use as its title.

searchPages

searchPages(string $query): array

Searches all Markdown titles for the given query string.

renderSidebar

renderSidebar(): string

Renders the sidebar (documentation menu) using getAvailablePages and renderPagesHierarchy.

Example Usage

$renderer = new DocumentationRenderer(__DIR__ . '/docs');
echo $renderer->renderSidebar();
echo $renderer->renderPage('getting_started');

Notes

Join our Discord
Discord Community