Giter Site home page Giter Site logo

phpdocumentor-markdown's Introduction

phpDocumentor - Generate GitHub/GitLab-Ready Markdown Documentation

Markdown template for phpDocumentor 3.x

Tests Status Generate Docs Status

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.

Example

An example is available in the example directory.

Installation & Usage

  • Please refer to this guide for instructions on installing phpDocumentor.
  • Usage instructions assume that phpDocumentor is the phpDocumentor 3.x binary.

Running manually

# Run phpDocumentor with --template argument pointed to this directory's markdown template
phpDocumentor --directory=src --target=docs --template=<PATH TO THIS REPOSITORY/themes/markdown>

Using Composer

Installation via Composer

# Require this package. You probably want it as a dev dependency
composer require --dev saggre/phpdocumentor-markdown

Running manually after installing via Composer

# Run phpDocumentor with --template argument pointed to markdown template inside vendor directory
phpDocumentor --directory=src --target=docs --template="vendor/saggre/phpdocumentor-markdown/themes/markdown"

Adding a Composer helper script

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'"
},

Using with PhpDocumentor XML config

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.

Running tests

# 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

Contributing

  • Use PSR-12 coding style
  • Twig extensions do not yet work with phpDocumentor3 (See #3041), so custom functionality is created with Twig macros.
  • The test suite uses Twig extensions to test the Twig macro functionality.
  • Check \phpDocumentor\Descriptor\ProjectDescriptor for data structure used to generate the documentation.

Inspired by:

phpdocumentor-markdown's People

Contributors

individual-it avatar saggre avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

phpdocumentor-markdown's Issues

Internal links

Suggestion: For internal links, remove the .md appendix in order to provide compatibility with Wiki pages. Current template opens raw md files instead of rendering it.

Error in creating links to parent interfaces

When I tried to create documentation for this interface:

<?php
/**
 * Файл с интерфейсом
 * события для `Selsyn`
 *
 * PHP version 8
 *
 * @category Event
 * @package  Selsyn
 * @author   Whatis <[email protected]>
 * @license  unlicense
 * @link     https://github.com/TheWhatis/Selsyn
 */

namespace Whatis\Selsyn\Event;

use Psr\EventDispatcher\StoppableEventInterface;

/**
 * Интерфейс для `Selsyn`
 *
 * PHP version 8
 *
 * @category Event
 * @package  Selsyn
 * @author   Whatis <[email protected]>
 * @license  unlicense
 * @link     https://github.com/TheWhatis/Selsyn
 */
interface IEvent extends StoppableEventInterface
{
    /**
     * Получить название события
     *
     * @return string
     */
    public static function getName(): string;
}

I got an error: strtr(): Argument #1 ($string) must be of type string, phpDocumentor\Descriptor\Collection given.

There was no time to wait until you read and correct (if you correct at all), so I myself found where the problem is.
I replaced this in the file interface.md.twig:

{% if node.parent and node.parent is not empty %}* Parent interface: {{ macros.mdClassLink(node.parent, macros.mdClassPath(node), node.parent.FullyQualifiedStructuralElementName) }}
{% endif %}

For this:

{% if node.parent and node.parent is not empty %}
* Parent interfaces: {% for parent in node.parent %}{% if loop.index0 > 0 %}{{ ', ' }}{% endif %}{{ macros.mdClassLink(parent, macros.mdClassPath(node), parent.FullyQualifiedStructuralElementName) }}{% endfor %}
{% endif %}

I would be grateful if you correct)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.