Read from the package's own PHP files at the commit 9ce91ac82a80: its namespaces, classes, interfaces and enums, their public constants, properties and methods with their PHPDoc, and the options its factories take. Nothing of it is run.
ConfigclassA source's options while its factory builds it: the options given, the factory's defaults under them, the keys that must be filled. Options come as configuration and environment variables give them: strings too.
8 methods
LinkerInterfaceinterfaceWhere a site publishes what a page links to. A source turns every link it reads into one of three: another page of the manual (page()), another file of the repository (file(): the source tree on its forge, at the commit read), a picture (image()). An address that is absolute, or only an anchor, is left as it was written.
3 methods
OnePageclassA version of a manual read as one page: every page in reading order, one after the other, so that a package's whole documentation is one address - read straight away, searched with the browser's own find in page, its table of contents in a sidebar.
10 methods · 2 properties
OnePartclassA page of a manual as a part of its one page (OnePage): where it starts, its HTML there, the file to edit.
2 methods · 8 properties
RegistryclassThe application's sources by name, each built once from its factory and options:
6 methods
SourceFactoryclassWhat a provider's factory has in common: its defaults set under the options given, the options it requires checked, then the source built.
1 method
SourceFactoryInterfaceinterfaceBuilds a source from its options (the folder it reads, the repository it comes from...).
2 methods
SourceInterfaceinterfaceOne version of a manual, as one format wrote it: a folder of Markdown, the output of Sphinx's JSON builder, Doxygen's XML, the JSON JSDoc explains.
4 methods
ExceptionInterfaceinterfaceEvery exception omnidocs and its sources throw.
InvalidConfigExceptionclassA source asked for with options it cannot work with: a folder that is not there, an option missing.
SourceExceptionclassWhat a source reads cannot be read: a file that is not the tool's output, a JSON or XML that does not parse.
ConventionsclassThe HTML every format renders to, so that one stylesheet and one script read a manual whatever wrote it - the conventions of symfony.com/doc:
9 methods · 2 constants
HeadingsclassThe headings of an HTML fragment that carry an id - on the heading, or on the element that wraps it (Sphinx's <section id>) - for "on this page" and the search index; and ids for texts that have none.
3 methods
LinksclassThe addresses of a page's links and pictures, rewritten: every <a href> and <img src> of an HTML fragment is handed to $rewrite (the address as written, decoded, and whether it is a picture), which answers the address to print or null to keep it. For the formats whose tool writes HTML (Sphinx's JSON builder); a Markdown source rewrites its links before rendering, on the document.
1 method
ProseclassA comment's prose as HTML - a PHPDoc's, a JSDoc's description: paragraphs at blank lines, a block indented by four spaces or more as code, lines that start with "-" or "*" as a list, `code` as code; everything else escaped.
1 method
TextclassThe plain text of an HTML fragment: what a reader reads, for a search index and a description.
1 method
RepositoryLinkerclassThe links of a manual read from a GitHub repository at a commit: a page goes where the site's closure says, another file of the repository to github.com at that commit (never a moving branch), a picture to raw.githubusercontent.com at that commit - or wherever the closures given say.
5 methods
HeadingclassA heading of a page: its level (1 to 6), the id it carries in the page's HTML - the anchor "on this page" and the search link to - and its text.
2 methods · 3 properties
ManualclassA manual: its key in the site's addresses, its title, the repository it is read from ("glitchr-studio/flowjs"), its versions by name and the one read by default - the current one; the others are older (or newer) series a site shows with a notice.
5 methods · 5 properties
NodeclassA place in a manual's contents: a page, or a section that holds pages (a folder of Markdown files, a Sphinx toctree caption, a group of API entries). Its path is its address inside the manual ("" for the home, "sticky", "guides/install"); a page knows the file it is read from, relative to the repository ("docs/sticky.md"), a section has none.
5 methods · 5 properties
PageclassA page of a manual, ready for a template: its path in the manual, its title, its contents (HTML, headings, metadata, plain text), the file it is read from relative to the repository - what "edit this page" opens - and the API entries it documents.
6 methods · 5 properties
RenderedclassA text once rendered to HTML: the HTML (without its first-level title when the format gives one, which the page prints itself), that title, the headings for "on this page", the metadata the source carried (a Markdown front matter), and its plain text for a search index and a description.
2 methods · 5 properties
SymbolclassAn entry of an API reference: a class, a function, a method, an option, a member... as the format names it. Its name is the one a reader searches and a cross-reference gives ("StickyStops.attach", "requests.get", "tinyxml2::XMLDocument::Parse"); it lives on a page of the manual, at an anchor of that page.
2 methods · 8 properties
VersionclassOne version of a manual ("1.x", "4.x", "main"): its source, the branch it follows and the commit it is read at, whether it has reached its end of life. Reads its pages in reading order - the home first, then the tree depth first - for the previous and next links.
10 methods · 5 properties
EntryclassOne record of a search index: what a hit shows and where it leads. Written with short keys, the index being downloaded whole by the reader's browser:
3 methods · 8 properties
SearchIndexclassThe search index of a static site: one JSON file, written with the site, that the reader's browser downloads once and searches (assets/omnidocs.js): the pages of each version given, a record per heading so that a hit lands on its section, a record per API entry, and whatever the site adds of its own (its guides, its news). Records keep the order they were added in, so that two builds write the same file.
6 methods
PathclassPaths inside a repository or a tool's output, written with "/".
7 methods
ArraySourceclassA manual written out in PHP, for an application's tests or a page that is no file: pages as [path => ['title' => ..., 'html' => ...]] (the order given is the reading order; "" is the home), symbols as Symbol objects.
5 methods
ArraySourceFactoryclassThe "array" factory: an ArraySource from its 'pages' option, for an application's tests.
2 options · 1 method
RecordingLinkerclassA linker for tests: pages at "/<path>", files at "repo:<path>", pictures at "img:<path>", and every request kept, so a test can check what a source linked to.
3 methods · 3 properties
SourceContractTeststraitWhat every source does, as PHPUnit tests: a provider's test case (or an application's, for a source of its own) uses this trait and gives the source, read from a real tool's output.
6 methods
Omnidocs
Config class
final class Config extends ArrayObject Config.php:14
A source's options while its factory builds it: the options given, the factory's defaults under them, the keys that must be filled. Options come as configuration and environment variables give them: strings too.
Config::defaults()
public function defaults(array $defaults): selfConfig::validateNotEmpty()
public function validateNotEmpty(array $keys, string $source): voidConfig::get()
public function get(string $key, mixed $default = null): mixedConfig::string()
public function string(string $key): ?stringA string option; null when it is empty.
Config::bool()
public function bool(string $key, bool $default = false): boolA boolean option, as an environment variable gives it too: "1", "true", "yes", "on".
Config::list()
public function list(string $key): arrayA list; one given as an environment variable is a comma-separated string.
Config::map()
public function map(string $key): arrayA map of strings ("note" => "Remarque").
Config::directory()
public function directory(string $key, string $source): stringA folder that must exist, without its trailing slash.
LinkerInterface interface
interface LinkerInterface LinkerInterface.php:12
Where a site publishes what a page links to. A source turns every link it reads into one of three: another page of the manual (page()), another file of the repository (file(): the source tree on its forge, at the commit read), a picture (image()). An address that is absolute, or only an anchor, is left as it was written.
LinkerInterface::page()
public function page(string $path, ?string $fragment = null): stringA page of the manual, by its path ("" the home), with its anchor.
LinkerInterface::file()
public function file(string $path, ?string $fragment = null): ?stringA file of the repository that is not a page ("src/js/stops.js"); null leaves the link as written.
LinkerInterface::image()
public function image(string $path): ?stringA picture, by its path in the repository or in the tool's output; null leaves it as written.
OnePage class
final class OnePage OnePage.php:40
A version of a manual read as one page: every page in reading order, one after the other, so that a package's whole documentation is one address - read straight away, searched with the browser's own find in page, its table of contents in a sidebar.
- the home comes first, as it is; every other page is a part: a section whose title is a second-level heading (its anchor, "sticky", from its path), its own headings one level down (its h2 becomes an h3), its ids prefixed with the part's anchor ("keys" becomes "sticky-keys"), so that no two ids of the page meet;
- a link from a page to another page of the manual goes to that part, in the page (#sticky, #sticky-keys); the linker given keeps the files of the repository and the pictures;
- the former addresses, one per page, are listed with the part they became and the prefix their anchors took (redirects()), for a static redirection that carries the visitor's #fragment over.
$one = new OnePage($manual->version(), $links, '/docs/flowjs/1.x'); $one->parts(); // the home, then each page: title, anchor, HTML, the file to edit $one->toc(); // the headings down to the third level, nested: the sidebar
With $groups, the manual's top-level sections (a folder, a toctree caption, a group of API entries) group its parts: the table of contents lists each section with its pages under it, and the page puts the section's title before its first part (div.doc-group, its own anchor). A section of a single page that bears its name is that page alone, not a group of one.
public readonly Version $versionpublic readonly string $urlThe page's own address: what search records and redirections lead to.
OnePage::__construct()
public function __construct(public readonly Version $version, readonly LinkerInterface $links, public readonly string $url, readonly int $tocLevel = 3, readonly bool $groups = false)OnePage::anchor()
public function anchor(string $path, ?string $fragment = null): stringThe anchor a page of the manual, or one of its headings, has in the one page; "" for the home's top.
OnePage::urlOf()
public function urlOf(string $path, ?string $fragment = null): stringThe address of a page of the manual, or one of its headings, in the one page.
OnePage::parts()
public function parts(): array- Returns
the home first, then every page in reading order
OnePage::groups()
public function groups(): arrayThe groups of the parts (with $groups): each top-level section, its anchor, its title, its pages' paths - but a section of one page that bears its name.
OnePage::html()
public function html(): stringThe parts' HTML, one after the other.
OnePage::headings()
public function headings(): array- Returns
every heading of the page, the parts' titles at the second level
OnePage::toc()
public function toc(): arrayThe table of contents: the second-level headings, each with its third-level ones (down to $tocLevel).
OnePage::text()
public function text(): stringThe page's text, for a description.
OnePage::redirects()
public function redirects(): arrayThe former address of each page but the home: its path => the part's anchor, and the prefix a #fragment of that address takes in the one page.
OnePart class
final class OnePart OnePart.php:9
A page of a manual as a part of its one page (OnePage): where it starts, its HTML there, the file to edit.
public readonly string $pathpublic readonly string $titlepublic readonly string $anchorIts anchor in the one page; "" for the home.
public readonly string $htmlpublic readonly array $headingsits title first (but for the home), then its own, one level down
public readonly ?string $sourceThe file it is read from, relative to the repository: "edit this page".
public readonly string $textpublic readonly Page $pageThe page as its source rendered it, on its own.
OnePart::__construct()
public function __construct(public readonly string $path, public readonly string $title, public readonly string $anchor, public readonly string $html, public readonly array $headings, public readonly ?string $source, public readonly string $text, public readonly Page $page)$headingsits title first (but for the home), then its own, one level down
OnePart::isHome()
public function isHome(): boolRegistry class
final class Registry Registry.php:18
The application's sources by name, each built once from its factory and options:
$docs = new Registry([new MarkdownSourceFactory(), new JsdocSourceFactory()], [ 'manual' => ['factory' => 'markdown', 'options' => ['root' => __DIR__.'/..', 'docs' => 'docs']], 'api' => ['factory' => 'jsdoc', 'options' => ['file' => __DIR__.'/var/jsdoc.json']], ]);
$docs->get('manual')->tree();
Registry::__construct()
public function __construct(iterable $factories, readonly array $config = [])Registry::get()
public function get(string $name): SourceInterfaceRegistry::has()
public function has(string $name): boolRegistry::names()
public function names(): arrayRegistry::create()
public function create(string $factory, array $options = []): SourceInterfaceA source built afresh by a factory, from options given here.
Registry::factories()
public function factories(): array- Returns
the factories installed: what
factory:may name
SourceFactory class
abstract class SourceFactory implements SourceFactoryInterface SourceFactory.php:9
What a provider's factory has in common: its defaults set under the options given, the options it requires checked, then the source built.
SourceFactory::create()
final public function create(array $options = []): SourceInterfaceSourceFactoryInterface interface
interface SourceFactoryInterface SourceFactoryInterface.php:6
Builds a source from its options (the folder it reads, the repository it comes from...).
SourceFactoryInterface::getName()
public function getName(): stringThe name sources are configured with: "markdown", "sphinx", "doxygen", "jsdoc".
SourceFactoryInterface::create()
public function create(array $options = []): SourceInterfaceSourceInterface interface
interface SourceInterface SourceInterface.php:18
One version of a manual, as one format wrote it: a folder of Markdown, the output of Sphinx's JSON builder, Doxygen's XML, the JSON JSDoc explains.
Every format answers the same three questions - the contents, a page, the API entries - so that a site renders any of them with the same templates.
A source reads files that already exist (a checkout, a build's output): it never runs the tool that wrote them, never reaches the network.
SourceInterface::home()
public function home(): ?NodeThe manual's home page, when the source has one ("" is its path).
SourceInterface::tree()
public function tree(): arrayThe contents, in reading order: pages, and sections holding pages.
The home is not in it.
SourceInterface::page()
public function page(string $path, ?LinkerInterface $links = null): ?PageA page rendered, by its path ("" for the home); null when there is none. Its links to other pages of the manual, to other files of the repository and its pictures go through $links: the site says where each one is published.
SourceInterface::symbols()
public function symbols(): arrayThe API entries the source documents, each on its page at its anchor; a manual of prose alone has none.
Omnidocs\Exception
ExceptionInterface interface
interface ExceptionInterface extends Throwable ExceptionInterface.php:6
Every exception omnidocs and its sources throw.
InvalidConfigException class
final class InvalidConfigException extends InvalidArgumentException implements ExceptionInterface InvalidConfigException.php:6
A source asked for with options it cannot work with: a folder that is not there, an option missing.
SourceException class
final class SourceException extends RuntimeException implements ExceptionInterface SourceException.php:6
What a source reads cannot be read: a file that is not the tool's output, a JSON or XML that does not parse.
Omnidocs\Html
Conventions class
final class Conventions Conventions.php:21
The HTML every format renders to, so that one stylesheet and one script read a manual whatever wrote it - the conventions of symfony.com/doc:
- a callout: <blockquote class="doc-callout doc-callout-note" data-label="Note">, for note, tip, important, warning, caution, seealso; versionadded and deprecated carry their version (data-version) and say it in their label;
- a version badge beside a heading: <span class="doc-version" data-version="1.4">;
- a code block in its frame: <div class="doc-code" data-lang="js">, its caption (a file name) above it in <div class="doc-code-caption">;
- code blocks side by side in tabs (YAML / PHP, npm / yarn): <div class="doc-tabs" data-doc-tabs>, a tab list of buttons and a panel each; without a script every panel shows, its title above it.
assets/omnidocs.js gives the tabs and a copy button to each frame.
const CALLOUTS = ['note', 'tip', 'important', 'warning', 'caution', 'seealso', 'versionadded', 'deprecated']const LABELS = ['note' => 'Note', 'tip' => 'Tip', 'important' => 'Important', 'warning' => 'Warning', 'caution' => 'Caution', 'seealso' => 'See also', 'versionadded' => 'Ne…The labels, in English; %version% is the callout's version.
Conventions::__construct()
public function __construct(readonly array $labels = [])The words a reader reads, in their language: any of LABELS' keys.
Conventions::label()
public function label(string $type, ?string $version = null): stringConventions::callout()
public function callout(string $type, string $inner, ?string $version = null): stringA callout around $inner (HTML).
Conventions::calloutAttributes()
public function calloutAttributes(string $type, ?string $version = null): array- Returns
the attributes of a callout's element, in their order
Conventions::versionBadge()
public function versionBadge(string $version, string $type = 'versionadded'): stringConventions::code()
public function code(string $code, ?string $language = null, ?string $caption = null): stringA code block in its frame. $code is HTML already (escaped, or coloured by a highlighter).
Conventions::tabs()
public function tabs(array $panels, string $id): stringPanels side by side, one shown at a time: [title => HTML]. $id makes the ids of its tabs and panels unique in the page ("tabs-1").
Conventions::attributes()
public static function attributes(array $attributes): stringConventions::escape()
public static function escape(string $text): stringHeadings class
final class Headings Headings.php:12
The headings of an HTML fragment that carry an id - on the heading, or on the element that wraps it (Sphinx's <section id>) - for "on this page" and the search index; and ids for texts that have none.
Headings::of()
public static function of(string $html, int $from = 2, int $to = 4): array$fromthe first level kept
$tothe last level kept
Headings::withoutPermalinks()
public static function withoutPermalinks(string $html): stringA heading's text without the permalink a tool adds to it (¶, #).
Headings::id()
public static function id(string $text, array &$taken = []): stringAn id for a text, unique among $taken (which it joins): "Scroll stops" → "scroll-stops", then "scroll-stops-1". Letters of any script are kept, as GitHub keeps them.
Links class
final class Links Links.php:13
The addresses of a page's links and pictures, rewritten: every <a href> and <img src> of an HTML fragment is handed to $rewrite (the address as written, decoded, and whether it is a picture), which answers the address to print or null to keep it. For the formats whose tool writes HTML (Sphinx's JSON builder); a Markdown source rewrites its links before rendering, on the document.
Links::rewrite()
public static function rewrite(string $html, callable $rewrite): stringProse class
final class Prose Prose.php:11
A comment's prose as HTML - a PHPDoc's, a JSDoc's description: paragraphs at
blank lines, a block indented by four spaces or more as code, lines that
start with "-" or "*" as a list, code as code; everything else escaped.
For the API references, whose tools give text, not Markdown.
Prose::toHtml()
public static function toHtml(string $text): stringParagraphs at blank lines, a block indented by four spaces or more as
code, lines starting with "-" or "*" as a list, code as code; everything else escaped.
Text class
final class Text Text.php:6
The plain text of an HTML fragment: what a reader reads, for a search index and a description.
Text::of()
public static function of(string $html): stringOmnidocs\Linking
RepositoryLinker class
final class RepositoryLinker implements LinkerInterface RepositoryLinker.php:19
The links of a manual read from a GitHub repository at a commit: a page goes where the site's closure says, another file of the repository to github.com at that commit (never a moving branch), a picture to raw.githubusercontent.com at that commit - or wherever the closures given say.
new RepositoryLinker( fn (string $path, ?string $fragment) => '/docs/'.$path.($fragment ? '#'.$fragment : ''), 'glitchr-studio/flowjs', 'c417356...', );
RepositoryLinker::__construct()
public function __construct(callable $page, readonly ?string $repository = null, readonly ?string $ref = null, ?callable $image = null, readonly string $forge = 'https://github.com', readonly string $raw = 'https://raw.githubusercontent.com')$imagea picture's address; raw.githubusercontent.com by default
RepositoryLinker::page()
public function page(string $path, ?string $fragment = null): stringRepositoryLinker::file()
public function file(string $path, ?string $fragment = null): ?stringRepositoryLinker::image()
public function image(string $path): ?stringRepositoryLinker::edit()
public function edit(string $path, string $branch): ?stringWhere a file is edited on the forge, at a branch: "edit this page".
Omnidocs\Model
Heading class
final class Heading Heading.php:9
A heading of a page: its level (1 to 6), the id it carries in the page's HTML - the anchor "on this page" and the search link to - and its text.
public readonly int $levelpublic readonly string $idpublic readonly string $text
Heading::__construct()
public function __construct(public readonly int $level, public readonly string $id, public readonly string $text)Heading::toArray()
public function toArray(): arrayManual class
final class Manual Manual.php:11
A manual: its key in the site's addresses, its title, the repository it is read from ("glitchr-studio/flowjs"), its versions by name and the one read by default - the current one; the others are older (or newer) series a site shows with a notice.
public readonly array $versionspublic readonly string $defaultpublic readonly string $keypublic readonly string $titlepublic readonly ?string $repository
Manual::__construct()
public function __construct(public readonly string $key, public readonly string $title, iterable $versions, ?string $default = null, public readonly ?string $repository = null)Manual::series()
public function series(): arrayManual::has()
public function has(string $series): boolManual::version()
public function version(?string $series = null): VersionManual::isCurrent()
public function isCurrent(string $series): boolNode class
final class Node Node.php:12
A place in a manual's contents: a page, or a section that holds pages (a folder of Markdown files, a Sphinx toctree caption, a group of API entries). Its path is its address inside the manual ("" for the home, "sticky", "guides/install"); a page knows the file it is read from, relative to the repository ("docs/sticky.md"), a section has none.
public readonly string $pathpublic readonly string $titlepublic readonly ?string $sourcepublic readonly int $orderpublic readonly array $children
Node::__construct()
public function __construct(public readonly string $path, public readonly string $title, public readonly ?string $source = null, public readonly int $order = 100, public readonly array $children = [], readonly bool $section = false)Node::section()
public static function section(string $path, string $title, array $children, int $order = 100): selfA section: a title over pages, not a page of its own.
Node::isSection()
public function isSection(): boolNode::contains()
public function contains(string $path): boolWhether this node, or a node under it, is the one at $path.
Node::flatten()
public static function flatten(array $tree): arrayEvery page of a tree, depth first, in reading order (sections left out).
Page class
final class Page Page.php:11
A page of a manual, ready for a template: its path in the manual, its title, its contents (HTML, headings, metadata, plain text), the file it is read from relative to the repository - what "edit this page" opens - and the API entries it documents.
public readonly string $pathpublic readonly string $titlepublic readonly Rendered $contentpublic readonly ?string $sourcepublic readonly array $symbols
Page::__construct()
public function __construct(public readonly string $path, public readonly string $title, public readonly Rendered $content, public readonly ?string $source = null, public readonly array $symbols = [])Page::html()
public function html(): stringPage::headings()
public function headings(): arrayPage::meta()
public function meta(): arrayPage::text()
public function text(): stringPage::excerpt()
public function excerpt(int $length = 220): stringRendered class
final class Rendered Rendered.php:11
A text once rendered to HTML: the HTML (without its first-level title when the format gives one, which the page prints itself), that title, the headings for "on this page", the metadata the source carried (a Markdown front matter), and its plain text for a search index and a description.
public readonly string $htmlpublic readonly ?string $titlepublic readonly array $headingspublic readonly array $metapublic readonly string $text
Rendered::__construct()
public function __construct(public readonly string $html, public readonly ?string $title = null, public readonly array $headings = [], public readonly array $meta = [], public readonly string $text = '')Rendered::excerpt()
public function excerpt(int $length = 220): stringThe plain text, its spaces collapsed, cut at $length characters with an ellipsis.
Symbol class
final class Symbol Symbol.php:12
An entry of an API reference: a class, a function, a method, an option, a member... as the format names it. Its name is the one a reader searches and a cross-reference gives ("StickyStops.attach", "requests.get", "tinyxml2::XMLDocument::Parse"); it lives on a page of the manual, at an anchor of that page.
public readonly string $kindWhat it is, in the format's words: "class", "function", "method", "member", "option", "py:function".
..
public readonly string $namepublic readonly string $pageThe page that documents it (its path in the manual).
public readonly ?string $anchorIts id in that page's HTML; null: the page itself.
public readonly string $summaryIts first sentence or so, as plain text.
public readonly ?string $signatureHow it is called or declared: "attach(scroller, options)".
public readonly ?string $parentThe entry it belongs to ("StickyStops" for "StickyStops.attach").
public readonly ?string $sourceWhere it is defined, relative to the repository: "src/js/stops.js#L1213".
Symbol::__construct()
public function __construct(public readonly string $kind, public readonly string $name, public readonly string $page, public readonly ?string $anchor = null, public readonly string $summary = '', public readonly ?string $signature = null, public readonly ?string $parent = null, public readonly ?string $source = null)Symbol::toArray()
public function toArray(): arrayVersion class
final class Version Version.php:14
One version of a manual ("1.x", "4.x", "main"): its source, the branch it follows and the commit it is read at, whether it has reached its end of life. Reads its pages in reading order - the home first, then the tree depth first - for the previous and next links.
public readonly string $namepublic readonly SourceInterface $sourcepublic readonly ?string $branchpublic readonly ?string $refThe commit (or tag) it is read at.
public readonly bool $eol
Version::__construct()
public function __construct(public readonly string $name, public readonly SourceInterface $source, public readonly ?string $branch = null, public readonly ?string $ref = null, public readonly bool $eol = false)Version::home()
public function home(): ?NodeVersion::tree()
public function tree(): arrayVersion::pages()
public function pages(): array- Returns
every page, the home first, then the tree depth first
Version::node()
public function node(string $path): ?NodeThe node of a page, by its path.
Version::page()
public function page(string $path, ?LinkerInterface $links = null): ?PageA page rendered, kept for the next call with the same linker.
Version::previous()
public function previous(string $path): ?NodeVersion::next()
public function next(string $path): ?NodeVersion::symbols()
public function symbols(): arrayVersion::symbol()
public function symbol(string $name): ?SymbolAn API entry by its name ("StickyStops.attach").
Omnidocs\Search
Entry class
final class Entry Entry.php:22
One record of a search index: what a hit shows and where it leads. Written with short keys, the index being downloaded whole by the reader's browser:
k its kind: "page", "heading", "symbol" - or a site's own ("guide", "news"...) t its title (a page's title, a heading's text, a symbol's name) u its address (with the anchor of a heading or a symbol) d a short text: the page's first words, what follows a heading, a symbol's summary h the page's headings, " · " between them x words searched but not shown in the title: a symbol's kind, a manual's name and version p the page a heading or a symbol is on s a symbol's signature
An empty field is left out.
public readonly string $kindpublic readonly string $titlepublic readonly string $urlpublic readonly string $textpublic readonly array $headingspublic readonly string $extrapublic readonly string $pagepublic readonly string $signature
Entry::__construct()
public function __construct(public readonly string $kind, public readonly string $title, public readonly string $url, public readonly string $text = '', public readonly array $headings = [], public readonly string $extra = '', public readonly string $page = '', public readonly string $signature = '')Entry::page()
public static function page(string $kind, string $title, string $url, string $text, array $headings = [], string $extra = '', int $maxLevel = 3): selfA page's entry, its headings down to $maxLevel listed.
Entry::toArray()
public function toArray(): arraySearchIndex class
final class SearchIndex SearchIndex.php:23
The search index of a static site: one JSON file, written with the site, that the reader's browser downloads once and searches (assets/omnidocs.js): the pages of each version given, a record per heading so that a hit lands on its section, a record per API entry, and whatever the site adds of its own (its guides, its news). Records keep the order they were added in, so that two builds write the same file.
$index = (new SearchIndex())->version($manual->version(), $links, extra: 'flowjs 1.x'); file_put_contents('search.json', $index->toJson('en'));
SearchIndex::add()
public function add(Entry ...$entries): selfSearchIndex::version()
public function version(Version $version, LinkerInterface $links, string $kind = 'page', string $extra = '', bool $headings = true, bool $symbols = true, int $headingLevel = 3, int $excerpt = 160, ?callable $title = null): selfEvery page of a version, its headings (levels 2 to $headingLevel) and its API entries.
$titlea page's title in the index (the page's own by default)
SearchIndex::onePage()
public function onePage(OnePage $one, string $title, string $kind = 'page', string $extra = '', bool $headings = true, bool $symbols = true, int $headingLevel = 3, int $excerpt = 160): selfA manual read as one page (OnePage): a record for the page, one per part (the pages it is made of), one per heading and one per API entry, each leading to its anchor in the one page.
SearchIndex::entries()
public function entries(): arraySearchIndex::toArray()
public function toArray(?string $locale = null): arraySearchIndex::toJson()
public function toJson(?string $locale = null): stringOmnidocs\Support
Path class
final class Path Path.php:6
Paths inside a repository or a tool's output, written with "/".
Path::normalise()
public static function normalise(string $path): ?string"docs/../src/./Foo.php" → "src/Foo.php"; null when it climbs out of its root.
Path::resolve()
public static function resolve(string $file, string $relative): ?string$relative read from the folder of $file ("docs/a.md" + "../README.md" → "README.md"); null outside the root.
Path::isAbsolute()
public static function isAbsolute(string $url): boolWhether a link is absolute (a scheme, "//host", "/path") or only an anchor: left as written.
Path::split()
public static function split(string $url): array["guides/install.md", "intro"] from "guides/install.md#intro"; the query left out.
Path::order()
public static function order(string $name, int $default = 100): array"10-getting-started" → [10, "getting-started"]; [100, $name] without a number.
Path::slug()
public static function slug(string $name): string"Getting Started!" → "getting-started": lower case ASCII letters, digits and dashes.
Path::humanise()
public static function humanise(string $slug): string"getting-started" → "Getting started".
Omnidocs\Testing
ArraySource class
final class ArraySource implements SourceInterface ArraySource.php:23
A manual written out in PHP, for an application's tests or a page that is no file: pages as [path => ['title' => ..., 'html' => ...]] (the order given is the reading order; "" is the home), symbols as Symbol objects.
A link written "page:<path>#<fragment>" in a page's HTML goes through the linker.
new ArraySource(['' => ['title' => 'Home', 'html' => '<p>Hi</p>'], 'install' => ['title' => 'Install', 'html' => '<h2 id="npm">npm</h2>']]);
ArraySource::__construct()
public function __construct(readonly array $pages, readonly array $symbols = [])ArraySource::home()
public function home(): ?NodeArraySource::tree()
public function tree(): arrayArraySource::page()
public function page(string $path, ?LinkerInterface $links = null): ?PageArraySource::symbols()
public function symbols(): arrayArraySourceFactory class
final class ArraySourceFactory extends SourceFactory ArraySourceFactory.php:10
The "array" factory: an ArraySource from its 'pages' option, for an application's tests.
Options
| Option | Default | |
|---|---|---|
pages | [] | required |
symbols | [] |
ArraySourceFactory::getName()
public function getName(): stringRecordingLinker class
final class RecordingLinker implements LinkerInterface RecordingLinker.php:12
A linker for tests: pages at "/<path>", files at "repo:<path>", pictures at "img:<path>", and every request kept, so a test can check what a source linked to.
public array $pages = []public array $files = []public array $images = []
RecordingLinker::page()
public function page(string $path, ?string $fragment = null): stringRecordingLinker::file()
public function file(string $path, ?string $fragment = null): ?stringRecordingLinker::image()
public function image(string $path): ?stringSourceContractTests trait
trait SourceContractTests SourceContractTests.php:22
What every source does, as PHPUnit tests: a provider's test case (or an application's, for a source of its own) uses this trait and gives the source, read from a real tool's output.
final class SphinxSourceTest extends TestCase { use SourceContractTests;
protected function source(): SourceInterface { return (new SphinxSourceFactory())->create(['dir' => __DIR__.'/Fixtures/requests']); }
}Requires phpunit/phpunit (the application's, in require-dev).
SourceContractTests::testItsContentsAreNodesWithOnePathEach()
public function testItsContentsAreNodesWithOnePathEach(): voidSourceContractTests::testEveryPageRendersWithTheAnchorsItLists()
public function testEveryPageRendersWithTheAnchorsItLists(): voidSourceContractTests::testAPathThatIsNoPageGivesNone()
public function testAPathThatIsNoPageGivesNone(): voidSourceContractTests::testItsLinksToItsOwnPagesGoToPagesItHas()
public function testItsLinksToItsOwnPagesGoToPagesItHas(): voidSourceContractTests::testEveryApiEntryIsOnAPageAtItsAnchor()
public function testEveryApiEntryIsOnAPageAtItsAnchor(): voidSourceContractTests::testAPageReadTwiceIsTheSame()
public function testAPageReadTwiceIsTheSame(): void