Generate Markdown documentation from PHP code
MIT License
Have you ever wished there was an easier way to generate documentation for your PHP source code? Well, now there is! With phpDocumentor and phpDocumentor-markdown, you can automatically generate GitHub/GitLab-ready Markdown documentation from your PHP source code. This template can be used to document classes, interfaces, traits, constants, properties and methods.
An example is available in the example directory.
phpDocumentor
is the phpDocumentor 3.x binary.# Run phpDocumentor with --template argument pointed to this directory's markdown template
phpDocumentor --directory=src --target=docs --template=<PATH TO THIS REPOSITORY/themes/markdown>
# Require this package. You probably want it as a dev dependency
composer require --dev saggre/phpdocumentor-markdown
# Run phpDocumentor with --template argument pointed to markdown template inside vendor directory
phpDocumentor --directory=src --target=docs --template="vendor/saggre/phpdocumentor-markdown/themes/markdown"
Add this script to your composer.json
and run composer create-docs
to generate the documentation.
"scripts": {
"create-docs": "phpDocumentor --directory=src --target=docs --template='vendor/saggre/phpdocumentor-markdown/themes/markdown'"
},
Add a template element to your phpDocumentor XML config and run phpDocumentor
to generate the documentation.
<phpdocumentor>
<!-- Specify template element inside phpdocumentor -->
<template name="./vendor/saggre/phpdocumentor-markdown/themes/markdown"/>
</phpdocumentor>
You can also check out the config file used for generating this repository's example documentation for a full example.
# Clone the repository
git clone [email protected]:Saggre/phpDocumentor-markdown.git
# Go to the cloned repository
cd phpDocumentor-markdown
# Install dependencies
composer install
# Set up PHPUnit configuration
cp phpunit.xml.dist phpunit.xml
# Run PHPUnit in project root directory
composer test
\phpDocumentor\Descriptor\ProjectDescriptor
for data structure used to generate the documentation.