Contents

API

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


Diagram

flowchart TD A[Start: DocumentationRenderer] --> B[Initialize Components] B --> C[Load PluginManager] B --> D[Load Markdown Parser] B --> E[Set Base Paths] C --> F{Request Type} D --> F E --> F F --> G[Render Page] F --> H[Get Available Pages] F --> I[Search Pages] F --> J[Render Sidebar] G --> K[Find Markdown File] H --> L[Scan Directory] I --> M[Query Content] J --> N[Build Navigation] K --> O[Apply Plugins] L --> P[Build Hierarchy] M --> Q[Filter Results] N --> R[Generate HTML] O --> S[Transform Content] P --> T[Sort Pages] Q --> U[Rank Results] R --> V[Output Sidebar] S --> W[Parse Markdown] T --> X[Return Array] U --> Y[Return Matches] V --> Z[Return HTML] W --> AA[Return Rendered Page] X --> BB[End] Y --> BB Z --> BB AA --> BB

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