A simple, directed markdown documentation generator for PHP projects.
A simple use-case is to generate a README.md based on the project's source code as well as other options as defined in the config file.
This projects allows you to define a set of directives for how to document a project, and output to markdown.
This allows everything from README's to entire websites to be generated using this tool.
This is done using a simple, expressive XML syntax. This includes:
- Automatic documentation of code
- Automatic composer requirements / installation instructions
- Raw and code-tag wrapped file inclusion
- Script output
- Automatic Badge Creation
- Creating sub-documents
- Much more
- php: >=7.2
- ext-dom: *
- ext-json: *
- ext-libxml: *
- donatj/cli-toolkit: ^0.3.1
- donatj/flags: ^1.5
- donatj/mddom: ^0.2.0
- phpdocumentor/reflection: ~5.2.0
- psr/log: ^1|^2|^3
- symfony/polyfill-php80: ^1.28
- PhpUserAgent's README
- boomerang.work - The documentation site for Boomerang*!* is fully generated using this tool.
This very README you are reading (also including DOCS.md) is generated by the file .mddoc.xml.dist
<mddoc>
<autoloader type="psr4" root="src" namespace="donatj\MDDoc"/>
<docpage target="README.md">
<section title="MDDoc">
<badge-poser type="version"/>
<badge-poser type="downloads"/>
<badge-poser type="license"/>
<badge-github-action name="donatj/mddoc" workflow-file="ci.yml"/>
<text><![CDATA[
A simple, directed markdown documentation generator for PHP projects.
A simple use-case is to generate a README.md based on the project's source code as well as other options as defined in the config file.
This projects allows you to define a set of directives for *how* to document a project, and output to markdown.
This allows everything from README's to entire websites to be generated using this tool.
This is done using a simple, expressive XML syntax. This includes:
- Automatic documentation of code
- Automatic composer requirements / installation instructions
- Raw and code-tag wrapped file inclusion
- Script output
- Automatic Badge Creation
- Creating sub-documents
- Much more
]]></text>
<section title="Requirements">
<composer-requires/>
</section>
<section title="Examples">
<text><![CDATA[
- PhpUserAgent's [README](https://github.com/donatj/PhpUserAgent)
- [boomerang.work](https://boomerang.work/) - The documentation site for Boomerang*!* is fully generated using this tool.
This very README you are reading (also including [DOCS.md](DOCS.md)) is generated by the file [.mddoc.xml.dist](.mddoc.xml.dist)
]]></text>
<replace search="	" replace=" ">
<source name=".mddoc.xml.dist" lang="xml"/>
</replace>
</section>
<section title="Full API Docs (WIP)">
<docpage target="DOCS.md">
<section title="Full API Docs (WIP)">
<recursive-directory warn-undocumented="false" name="src"/>
</section>
</docpage>
</section>
<section title="Configuration Syntax">
<exec cmd="./bin/document-tags.php"/>
</section>
</section>
</docpage>
</mddoc>
Specifies an PHP autoloader to use for the documentation generation
This autoloader is used at the current documentation level and inherited by
all children
Multiple autoloaders can be specified, and they will be checked in the order
they are specified
These are necessary to specify by hand because the composer autoloaders
do not provide a method to locate a class by name without loading it,
which is necessary for documentation generation without code execution.
type
(required) - The type of autoloader to use, either "psr0" or "psr4"root
(required) - The root directory of the autoloadernamespace
- The namespace of the autoloader, only used for psr4
Define a logical section of the generated documentation
Nesting sections results in the header level being increased (h1, h2, h3, etc)
Example:
<section title="This is an H1">
<section title="This is an H2">
<section title="This is an H3">
<text>Some Text</text>
</section>
</section>
</section>
Results in:
# This is an H1
## This is an H2
### This is an H3
Some Text
title
(required) - The heading of the section
Replace text in the wrapped content. Optionally use a preg_replace() regex.
search
(required) - The text to search forreplace
(required) - The text to replace withregex
- Whether to use a regex or not - expects "true" or "false" - defaults to "false"
Documentation page - stores the contents of child elements to a file
Nesting docpages results in a link being added in the parent page to the child page
Inherits all attributes from <file>
target
(required) - Filename to outputlink
- Optional custom link for parent documentslink-text
- Optional custom text for the link in parent documentslink-pre-text
- Optional custom text to precede the link in parent documentslink-post-text
- Optional custom text to follow the link in parent documents
Include either raw or cdata text content
Example:
<text>Some Text</text>
<text><![CDATA[Some Text]]></text>
Generate documentation for a single PHP file
name
(required) - The file to documentskip-class-header
[recursive] - Skip the class header lineskip-class-constants
[recursive] - Skip the class constants sectionmethod-filter
- Regex to filter methods by - specify methods to be matchedskip-method-returns
- Skip the method return sectionwarn-undocumented
[recursive] - Generate warning for undocumented methods. Defaults to "true".
Recursively search a directory for php files to generate documentation for
name
(required) - The directory to recursively search for files to documentfile-filter
- A regex to filter files by - specify files to be matched
Include the contents of a file
name
(required) - The poth of the file to include
Include a source code block either as a file or inline
Example:
<source name="path/to/file.php" lang="php" />
<source lang="js">
console.log('Hello World');
</source>
name
- filename of optional source filelang
- Optional language name for the opening
Reads the current projects' composer.json file and outputs the install command
text
- Text to display before the install commandglobal
- Whether to include global subcommanddev
- Whether to include --dev flagpackage-names
- Package name override. Comma delimited. Defaults toname
key of composer.json
Reads the current projects' composer.json file and outputs the required packages, versions and extensions
Include a badge "shield" image from a given url
src
- The image url (required)alt
- The image alt text (required)href
- The optional url to link to wrap the badge intitle
- The optional link title
Include a coverage badge from BadgeCoveralls.io
name
- The BadgeCoveralls name of the Project. Required.
This includes the service name, e.g. "github/donatj/php-dnf-solver"
branch
- The branch to show. Defaults to empty which shows the default branch
Include a badge "shield" image from Pugx Poser https://poser.pugx.org/
type
(required) - The type of badge to display. One of: "version" "downloads" "unstable" "license" "monthly" "daily" "phpversion"
"composerlock"name
- The packagist name of the package. Defaults to the name key of the composer.json file in the root of the project. Required if the composer.json file is not present.suffix
- The poser endpoint to use. Defaults based on the type
Include a badge "shield" image from Travis CI
name
(required) - The packagist name of the Travis Project. Defaults to the name key of the composer.json file in the root of the
project. Required if the composer.json file is not present.branch
- The branch to show. Defaults to "master"
Include a badge "shield" image from Scrutinizer CI
name
(required) - The packagist name of the Scrutinizer Project. Defaults to the name key of the composer.json file in the root of
the project. Required if the composer.json file is not present.type
(required) - The type of badge to display. One of: "quality" "coverage" "build-status"suffix
- The Scrutinizer endpoint to use. Defaults based on the typebranch
- The branch to show. Defaults to "master"
Include a badge "shield" image from Shielded.dev
Either the id or the color, title, and text options must be provided.
id
- The ID of the badge to display when displaying a dynamic badge.color
- The color of the badge when displaying a static badge.title
- The title of the badge when displaying a static badge.text
- The text of the badge when displaying a static badge.
Include a badge "shield" image for a GitHub Actions workflow
name
(required) - The name of the.yml
file in the.github/workflows/
directory including the.yml
extensionbranch
- The name of the branch to show the badge for. Defaults to the default branch.event
workflow-file
(required) - The filename of the workflow file to use as the badge source
Execute a command and include the standard output in the documentation
cmd
(required) - The command to executeformat
- The format to output the result in - options include "raw" "code" and "code-block" defaults to "raw"allow-error
- Set to 'true' to allow non-zero exit codes to continue