Download the PHP package berlioz/doc-parser without Composer
On this page you can find all versions of the php package berlioz/doc-parser. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download berlioz/doc-parser
More information about berlioz/doc-parser
Files in berlioz/doc-parser
Package doc-parser
Short Description Berlioz Doc Parser is a PHP library to parse documentation and allow to integrate this on website for example.
License MIT
Homepage https://getberlioz.com
Informations about the package doc-parser
Berlioz Doc Parser
Berlioz Doc Parser is a PHP library to parse documentation and allow to integrate this on website for example.
Installation
Composer
You can install Berlioz Doc Parser with Composer, it's the recommended installation.
Dependencies
- PHP ^8.0
- PHP libraries:
- mbstring
- Packages:
- berlioz/html-selector
- berlioz/http-message
- league/flysystem
To parse files, you need additional package:
- For MarkDown files:
league/commonmark
- For reStructuredText files:
gregwar/rst
Usage
Library use league/flysystem
library to manipulate files.
This library permit to use some adapter like Local files, GitLab, Google... that's very useful for documentation source.
Documentation generation
You need to define the parser of you documentation, in the example: Berlioz\DocParser\Parser\Markdown
.
Documentation files
You can access to documentation files easily:
And filter the files by type:
Two file type exists:
Berlioz\DocParser\Doc\File\Page
: page with parsed contentBerlioz\DocParser\Doc\File\RawFile
: raw file like images
Documentation handle
When your documentation is generate, you can use Documentation::handle()
method to get pages and files.
Treatments
A concept of treatment is implement to manipulate files after generation.
Some treatments are activate by default:
Berlioz\DocParser\Treatment\DocSummaryTreatment
: generate the summary of documentationBerlioz\DocParser\Treatment\PageSummaryTreatment
: generate the pages summariesBerlioz\DocParser\Treatment\PathTreatment
: resolve all links to transform in relative linksBerlioz\DocParser\Treatment\TitleTreatment
: extract title of page and set toPage
object
Optionals treatments are available:
Berlioz\DocParser\Treatment\BootstrapTreatment
: add CSS classes to HTML elements to beautify them for Bootstrap framework
You can also create your treatment class and add this to generator:
Formats
MarkDown
A specific tag is for indexation of documentation.
reStructuredText
A specific directive is for indexation of documentation.
...index:
:title: Title of page
:slug: Slug name (replace only the filename, not path)
:breadcrumb: Category; Sub category; My page
:summary-order: 1
:summary-visible: true
Options available for indexation
title
: replace the title of page, the title treatment does not replace this titleslug
: replace the filename of page, not the complete path, it's an url encoded representation of valuebreadcrumb
: the breadcrumb of page into the documentation summary, if not present, the page will not in the summarysummary-order
: the order in summary sectionsummary-visible
: default to true, but you can define the page to not visible in summary
You can define your own options, for your treatments for example, options are available with Page::getMeta(...)
method.
Summary
Doc summary
Doc summary references all pages with a breadcrumb.
It's a hierarchy of Berlioz\DocParser\Doc\Summary\Entry
objects.
You can get path of entry with method Entry::getPath()
, it's the absolute path from root directory of documentation.
Page summary
Page summary references all headings in the page content.
It's a hierarchy of Berlioz\DocParser\Doc\Summary\Entry
objects.
No path given to the entry, but an id Entry::getId()
linked to the corresponding heading.
Parser
Two parser are available by default:
Berlioz\DocParser\Parser\Markdown
: to parse MarkDown files, useleague/commonmark
packageBerlioz\DocParser\Parser\reStructuredText
: to parse reStructuredText files, usegregwar/rst
package
You can also create your own parser, you need only to implement Berlioz\DocParser\Parser\ParserInterface
interface.
If you need to add an extension to a specific parser, a getter method is available to access to the original parser. Example for MarkDown parser: \Berlioz\DocParser\Parser\Markdown::getCommonMarkConverter()
.
You can also pass to the Markdown
and reStructuredText
constructors the same parameters that corresponding libraries.
Cache
Generation of documentation take time, and it's not acceptable to generate documentation at every request.
Berlioz\DocParser\DocCacheGenerator
class generate a cache of generated and treated documentation to reuse it quickly.
The cache use league/flysystem
package to store cache files.
Example of usage:
All versions of doc-parser with dependencies
ext-mbstring Version *
berlioz/helpers Version ^1.5
berlioz/html-selector Version ^2.0
berlioz/http-message Version ^2.0
league/flysystem Version ^2.0