PHP Classes

Sphinx PHP Doc RST : Generate Sphinx documentation from PHPDoc comments

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 43 All time: 10,860 This week: 560Up
Version License PHP version Categories
phpdoc-to-rst 1.0.0MIT/X Consortium ...7PHP 5, Tools, Parsers
Collaborate with this project 

Author

phpdoc-to-rst - github.com

Description

This package can generate Sphinx documentation from PHPDoc comments.

It can traverse the PHP source code files and parses them to extract documentation of class functions and variables.

The package can generate output in Sphinx ReStructured Text format.

Innovation Award
PHP Programming Innovation award nominee
August 2019
Number 2
Sphinx is the name of a format and a tool to generate documentation for the Python language.

Like the Python language, it uses indentation to show the different levels of nested content in a way that makes it more readable what is the level of nesting of document blocks that are contained in the respective parent document blocks.

This package can generate documentation in Sphinx format from PHP classes that contain function and variable documentation details in comments formatted in the PHPDoc format.

Manuel Lemos
Picture of Francesco Danti
  Performance   Level  
Innovation award
Innovation award
Nominee: 2x

 

Documentation

phpdoc-to-rst

Build Status Coverage Status Codacy Badge

Scrutinizer Code Quality Code Coverage Build Status

Forked and refactor by Francesco "Abbadon1334" Danti.

Now working as intended, with good coverage.

Generate reStructuredText for Sphinx based documentation from PHPDoc annotations.

This project is heavily based on phpDocumentor/Reflection and makes use of sphinxcontrib-phpdomain.

An example for the documentation output can be found in our own documentation

Quickstart

Install phpdoc-to-rst to your project directory:


composer require --dev abbadon1334/phpdoc-to-rst

Command line usage

Run the command line tool to parse the folders containing your PHP tree and render the reStructuredText files to the output directory:

php vendor/bin/phpdoc-to-rst generate --repo-base "$PWD" --repo-github https://github.com/abbadon1334/phpdoc-to-rst -t docs/rst/ src/

Programatically usage to generate documentation rst


    // your source path or multiple path to be parsed
    $src = [__DIR__.'/../src'];
    
    // destination path for the documentation
    $dst = __DIR__.'/../docs/api';
    
    $apiDocBuilder = new ApiDocBuilder($src, $dst);
    
    // DEBUG FATURES : optional
    // optional : activate verbosity
    $apiDocBuilder->setVerboseOutput(true);
    // optional : activate debug
    $apiDocBuilder->setDebugOutput(true);
    
    // EXTENSIONS : optional
        
    /
     * Do not render classes marked with phpDoc internal tag
     * Do only render public methods/properties.
     */
    $apiDocBuilder->addExtension(PublicOnlyExtension::class);
        
    /
     * Do not render classes marked with phpDoc internal tag
     * Do only render public methods/properties.
     */
    $apiDocBuilder->addExtension(NoPrivateExtension::class);
        
    /
     * This extension will render a list of methods  for easy access
     * at the beginning of classes, interfaces and traits.
     */
    $apiDocBuilder->addExtension(TocExtension::class);
        
    /
     * This extension adds a link to the source at github to all elements.
     *
     * Arguments
     * 0 => Url to the github repo (required)
     * 1 => Path to the git repository (required)
     * 2 => Branch to link to (default=master)
     */
    $apiDocBuilder->addExtension(GithubLocationExtension::class, [
        __DIR__.'/../src',
        'http://github.com/abbadon1334/phpdoc-to-rst/',
    ]);
    
    // Build documentation
    $apiDocBuilder->build();


  Files folder image Files (161)  
File Role Description
Files folder imagebin (1 file)
Files folder imagedocs (8 files, 4 directories)
Files folder imageexample (1 file)
Files folder imagesrc (3 files, 3 directories)
Accessible without login Plain text file .readthedocs.yml Data Auxiliary data
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file Makefile Data Auxiliary data
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation
Accessible without login Plain text file renovate.json Data Auxiliary data

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:43
This week:0
All time:10,860
This week:560Up