{"id":20525554,"url":"https://github.com/code-lts/doctum","last_synced_at":"2025-05-14T20:04:31.158Z","repository":{"id":39494276,"uuid":"274740184","full_name":"code-lts/doctum","owner":"code-lts","description":"A php API documentation generator, fork of Sami","archived":false,"fork":false,"pushed_at":"2025-04-03T12:20:30.000Z","size":34385,"stargazers_count":324,"open_issues_count":18,"forks_count":37,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-13T14:06:01.972Z","etag":null,"topics":["doctum","documentation","documentation-generator","long-term-support","php"],"latest_commit_sha":null,"homepage":"https://doctum.long-term.support/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/code-lts.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"tidelift":"packagist/code-lts/doctum","github":"williamdes"}},"created_at":"2020-06-24T18:22:37.000Z","updated_at":"2025-04-07T22:00:11.000Z","dependencies_parsed_at":"2023-11-24T13:30:24.035Z","dependency_job_id":"0cd3bb72-1959-47c0-b8c0-69cfbf949d3b","html_url":"https://github.com/code-lts/doctum","commit_stats":{"total_commits":871,"total_committers":73,"mean_commits":"11.931506849315069","dds":"0.35591274397244543","last_synced_commit":"7ab4c804e2f18d53e9d9931e9eddb9c70ce03ddc"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-lts%2Fdoctum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-lts%2Fdoctum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-lts%2Fdoctum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-lts%2Fdoctum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/code-lts","download_url":"https://codeload.github.com/code-lts/doctum/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248724639,"owners_count":21151561,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["doctum","documentation","documentation-generator","long-term-support","php"],"created_at":"2024-11-15T23:06:09.951Z","updated_at":"2025-04-13T14:06:10.412Z","avatar_url":"https://github.com/code-lts.png","language":"PHP","funding_links":["https://tidelift.com/funding/github/packagist/code-lts/doctum","https://github.com/sponsors/williamdes"],"categories":[],"sub_categories":[],"readme":"Doctum, a PHP API documentation generator. Fork of Sami\n=========================================================\n\nCurious about what Doctum generates? Have a look at the `MariaDB MySQL Kbs`_ or `Laravel`_ documentation.\n\nOur badges\n----------\n\n.. image:: https://img.shields.io/badge/GitHub%20marketplace%20action-available-green.svg\n    :alt: GitHub marketplace action\n    :target: https://github.com/marketplace/actions/action-doctum\n\n.. image:: https://codecov.io/gh/code-lts/doctum/branch/main/graph/badge.svg?branch=main\n    :alt: Project code coverage by Codecov\n    :target: https://codecov.io/gh/code-lts/doctum\n\n.. image:: https://github.com/code-lts/doctum/actions/workflows/tests.yml/badge.svg?branch=main\n    :alt: Project test suite\n    :target: https://github.com/code-lts/doctum/actions/workflows/tests.yml\n\nInstallation\n------------\n\n.. caution::\n\n    Doctum requires **PHP 7.2.20** or later.\n\nGet Doctum as a `phar file`_:\n\n.. code-block:: bash\n\n    $ curl -O https://doctum.long-term.support/releases/latest/doctum.phar\n\nYou can also find some alternative phar versions:\n\n- ``major``\n- ``major``. ``minor`` (any version since 5.1)\n- ``major``. ``minor``. ``patch``\n- `latest \u003chttps://doctum.long-term.support/releases/latest/doctum.phar\u003e`_\n- `dev \u003chttps://doctum.long-term.support/releases/dev/doctum.phar\u003e`_ (not always up to date)\n- ``major``-dev\n- ``major``. ``minor``-dev (most of the time it exists)\n- ``major``. ``minor``. ``patch``-dev (sometimes it exists)\n\n.. code-block:: bash\n\n    $ curl -O https://doctum.long-term.support/releases/${version}/doctum.phar \u0026\u0026 chmod +x doctum.phar\n\nCheck that everything worked as expected by executing the ``doctum.phar`` file\nwithout any arguments:\n\n.. code-block:: bash\n\n    $ doctum.phar\n\nSince 5.3.0 the phar does not require to use `php` keyword anymore because the `shebang` was added to the phar file.\nYou can now call `doctum.phar` directly after adding execution rights onto the file.\n\nYou can use our `GitHub marketplace action \u003chttps://github.com/marketplace/actions/action-doctum\u003e`_ into your GitHub CI.\n\nConfiguration\n-------------\n\nBefore generating documentation, you must create a configuration file. Here is\nthe simplest possible one:\n\n.. code-block:: php\n\n    \u003c?php\n\n    return new Doctum\\Doctum('/path/to/yourlib/src');\n\nThe configuration file must return an instance of ``Doctum\\Doctum`` and the first\nargument of the constructor is the path to the code you want to generate\ndocumentation for.\n\nActually, instead of a directory, you can use any valid PHP iterator (and for\nthat matter any instance of the Symfony `Finder`_ class):\n\n.. code-block:: php\n\n    \u003c?php\n\n    use Doctum\\Doctum;\n    use Symfony\\Component\\Finder\\Finder;\n\n    $iterator = Finder::create()\n        -\u003efiles()\n        -\u003ename('*.php')\n        -\u003eexclude('Resources')\n        -\u003eexclude('Tests')\n        -\u003ein('/path/to/yourlib/src');\n\n    return new Doctum($iterator);\n\nThe ``Doctum`` constructor optionally takes an array of options as a second\nargument:\n\n.. code-block:: php\n\n    return new Doctum($iterator, [\n        'title'                =\u003e 'yourlib API',\n        'language'             =\u003e 'en', // Could be 'fr'\n        'build_dir'            =\u003e __DIR__ . '/build',\n        'cache_dir'            =\u003e __DIR__ . '/cache',\n        'source_dir'           =\u003e '/path/to/repository/',\n        'remote_repository'    =\u003e new GitHubRemoteRepository('username/repository', '/path/to/repository'),\n        'default_opened_level' =\u003e 2, // optional, 2 is the default value\n    ]);\n\nAnd here is how you can configure different versions:\n\n.. code-block:: php\n\n    \u003c?php\n\n    use Doctum\\Doctum;\n    use Doctum\\RemoteRepository\\GitHubRemoteRepository;\n    use Doctum\\Version\\GitVersionCollection;\n    use Symfony\\Component\\Finder\\Finder;\n\n    $dir = '/path/to/yourlib/src';\n    $iterator = Finder::create()\n        -\u003efiles()\n        -\u003ename('*.php')\n        -\u003eexclude('Resources')\n        -\u003eexclude('Tests')\n        -\u003ein($dir);\n\n    // generate documentation for all v2.0.* tags, the 2.0 branch, and the main one\n    $versions = GitVersionCollection::create($dir)\n        // In a non case-sensitive way, tags containing \"PR\", \"RC\", \"BETA\" and \"ALPHA\" will be filtered out\n        // To change this, use: `$versions-\u003esetFilter(static function (string $version): bool { // ... });`\n        -\u003eaddFromTags('v2.0.*')\n        -\u003eadd('2.0', '2.0 branch')\n        -\u003eadd('main', 'main branch');\n\n    return new Doctum($iterator, [\n        'versions'             =\u003e $versions,\n        'title'                =\u003e 'yourlib API',\n        'language'             =\u003e 'en', // Could be 'fr'\n        'build_dir'            =\u003e __DIR__ . '/../build/sf2/%version%',\n        'cache_dir'            =\u003e __DIR__ . '/../cache/sf2/%version%',\n        'source_dir'           =\u003e dirname($dir) . '/',\n        'remote_repository'    =\u003e new GitHubRemoteRepository('yourorg/yourlib', dirname($dir)),\n        'default_opened_level' =\u003e 2, // optional, 2 is the default value\n    ]);\n\n\nAnd here is how you can configure a footer link below the Doctum link:\n\nAll `footer_link` keys are optional.\n\n.. code-block:: php\n\n    \u003c?php\n\n    use Doctum\\Doctum;\n    use Symfony\\Component\\Finder\\Finder;\n\n    $dir = '/path/to/yourlib/src';\n    $iterator = Finder::create()\n        -\u003efiles()\n        -\u003ename('*.php')\n        -\u003eexclude('Resources')\n        -\u003eexclude('Tests')\n        -\u003ein($dir);\n\n    return new Doctum($iterator, [\n        'title'                =\u003e 'yourlib API',\n        'source_dir'           =\u003e dirname($dir) . '/',\n        'remote_repository'    =\u003e new GitHubRemoteRepository('yourorg/yourlib', dirname($dir)),\n        'footer_link'          =\u003e [\n            'href'        =\u003e 'https://github.com/code-lts/doctum',\n            'rel'         =\u003e 'noreferrer noopener',\n            'target'      =\u003e '_blank',\n            'before_text' =\u003e 'You can edit the configuration',\n            'link_text'   =\u003e 'on this', // Required if the href key is set\n            'after_text'  =\u003e 'repository',\n        ],\n    ]);\n\nTo enable `OpenSearch \u003chttps://en.wikipedia.org/wiki/OpenSearch\u003e`_ feature in your users browsers:\n\n.. code-block:: php\n\n    \u003c?php\n\n    use Doctum\\Doctum;\n    use Symfony\\Component\\Finder\\Finder;\n\n    $dir = '/path/to/yourlib/src';\n    $iterator = Finder::create()\n        -\u003efiles()\n        -\u003ename('*.php')\n        -\u003eexclude('Resources')\n        -\u003eexclude('Tests')\n        -\u003ein($dir);\n\n    return new Doctum($iterator, [\n        'title'    =\u003e 'Project Api Documentation',\n        // Necessary to enable the opensearch.xml file generation\n        'base_url' =\u003e 'https://apidocs.company.tld/',\n        // If you have a favicon\n        // 'favicon' =\u003e 'https://company.tld/favicon.ico',\n        // ... more configs\n    ]);\n\nYou can find more configuration examples under the ``examples/`` directory of\nthe source code.\n\nDoctum only documents the public API (public properties and methods); override\nthe default configured ``filter`` to change this behavior:\n\n.. code-block:: php\n\n    \u003c?php\n\n    use Doctum\\Parser\\Filter\\TrueFilter;\n\n    $doctum = new Doctum(...);\n    // document all methods and properties\n    $doctum['filter'] = function () {\n        return new TrueFilter();\n    };\n\nRendering\n---------\n\nNow that we have a configuration file, let's generate the API documentation:\n\n.. code-block:: bash\n\n    $ doctum.phar update /path/to/config.php\n\nThe generated documentation can be found under the configured ``build/``\ndirectory (note that the client side search engine does not work on Chrome due\nto JavaScript execution restriction, unless Chrome is started with the\n\"--allow-file-access-from-files\" option -- it works fine in Firefox).\n\nBy default, Doctum is configured to run in \"incremental\" mode. It means that when\nrunning the ``update`` command, Doctum only re-generates the files that needs to\nbe updated based on what has changed in your code since the last execution.\n\nDoctum also detects problems in your phpdoc and can tell you what you need to fix\nif you add the ``-v`` option:\n\n.. code-block:: bash\n\n    $ doctum.phar update /path/to/config.php -v\n\nCreating a Theme\n----------------\n\nIf the default themes do not suit your needs, you can very easily create a new\none, or just override an existing one.\n\nA theme is just a directory with a ``manifest.yml`` file that describes the\ntheme (this is a YAML file):\n\n.. code-block:: yaml\n\n    name:   markdown-custom\n    parent: default\n\nThe above configuration creates a new ``markdown-custom`` theme based on the\n``default`` built-in theme. To override a template, just create a file with\nthe same name as the original one. For instance, here is how you can extend the\ndefault class template to prefix the class name with \"Class \" in the class page\ntitle:\n\n.. code-block:: twig\n\n    {# pages/class.twig #}\n\n    {% extends 'default/pages/class.twig' %}\n\n    {% block title %}Class {{ parent() }}{% endblock %}\n\nIf you are familiar with Twig, you will be able to very easily tweak every\naspect of the templates as everything has been well isolated in named Twig\nblocks.\n\nA theme can also add more templates and static files. Here is the manifest for\nthe default theme:\n\n.. code-block:: yaml\n\n    name: default\n\n    static:\n        'css/doctum.css': 'css/doctum.css'\n        'css/bootstrap.min.css': 'css/bootstrap.min.css'\n        'css/bootstrap-theme.min.css': 'css/bootstrap-theme.min.css'\n        'fonts/doctum-font.css': 'fonts/doctum-font.css'\n        'fonts/doctum.woff': 'fonts/doctum.woff'\n        'fonts/doctum.woff2': 'fonts/doctum.woff2'\n        'fonts/doctum.ttf': 'fonts/doctum.ttf'\n        'fonts/doctum.svg': 'fonts/doctum.svg'\n        'fonts/doctum.eot': 'fonts/doctum.eot'\n        'js/jquery-3.5.1.slim.min.js': 'js/jquery-3.5.1.slim.min.js'\n        'js/bootstrap.min.js': 'js/bootstrap.min.js'\n        'js/autocomplete.min.js': 'js/autocomplete.min.js'\n\n    global:\n        'index.twig':      'index.html'\n        'doc-index.twig':  'doc-index.html'\n        'namespaces.twig': 'namespaces.html'\n        'classes.twig':    'classes.html'\n        'interfaces.twig': 'interfaces.html'\n        'traits.twig':     'traits.html'\n        'opensearch.twig': 'opensearch.xml'\n        'search.twig':     'search.html'\n        'doctum.js.twig':  'doctum.js'\n\n    namespace:\n        'namespace.twig': '%s.html'\n\n    class:\n        'class.twig': '%s.html'\n\n\nFiles are contained into sections, depending on how Doctum needs to treat them:\n\n* ``static``: Files are copied as is (for assets like images, stylesheets, or\n  JavaScript files);\n\n* ``global``: Templates that do not depend on the current class context;\n\n* ``namespace``: Templates that should be generated for every namespace;\n\n* ``class``: Templates that should be generated for every class.\n\n.. _Finder: https://symfony.com/doc/current/components/finder.html\n.. _phar file: https://doctum.long-term.support/releases/latest/doctum.phar\n.. _MariaDB MySQL Kbs: https://williamdes.github.io/mariadb-mysql-kbs/\n.. _Laravel: https://laravel.com/api/master/index.html\n\nTheme configuration\n~~~~~~~~~~~~~~~~~~~\n\n.. code-block:: php\n\n    \u003c?php\n\n    return new Doctum($iterator, [\n        // [...]\n        'theme'         =\u003e 'my-theme-name',\n        // Add the path to the theme/themes\n        'template_dirs' =\u003e [__DIR__ . '/themes/my-theme-name'],\n        // [...]\n        ]\n    );\n\nSearch Index\n~~~~~~~~~~~~\n\nThe autocomplete and search functionality of Doctum is provided through a\nsearch index that is generated based on the classes, namespaces, interfaces,\nand traits of a project. You can customize the search index by overriding the\n``search_index_extra`` block of ``doctum.js.twig``.\n\nThe ``search_index_extra`` allows you to extend the default theme and add more\nentries to the index. For example, some projects implement magic methods that\nare dynamically generated at runtime. You might wish to document these methods\nwhile generating API documentation and add them to the search index.\n\nEach entry in the search index is a JavaScript object that contains the\nfollowing keys:\n\ntype\n    The type associated with the entry. Built-in types are \"Class\",\n    \"Namespace\", \"Interface\", \"Trait\". You can add additional types specific\n    to an application, and the type information will appear next to the search\n    result.\n\nname\n    The name of the entry. This is the element in the index that is searchable\n    (e.g., class name, namespace name, etc).\n\nfromName\n    The parent of the element (if any). This can be used to provide context for\n    the entry. For example, the fromName of a class would be the namespace of\n    the class.\n\nfromLink\n    The link to the parent of the entry (if any). This is used to link a child\n    to a parent. For example, this would be a link from a class to the class\n    namespace.\n\ndoc\n    A short text description of the entry.\n\nOne such example of when overriding the index is useful could be documenting\ndynamically generated API operations of a web service client. Here's a simple\nexample that adds dynamically generated API operations for a web service client\nto the search index:\n\n.. code-block:: twig\n\n    {% extends \"default/doctum.js.twig\" %}\n\n    {% block search_index_extra %}\n        {% for operation in operations -%}\n            {\n                type: 'Operation'|trans,\n                link: operation.path,\n                name: operation.name,\n                doc: operation.doc,\n            }|json_encode|raw\n        {%- endfor %}\n    {% endblock %}\n\nThis example assumes that the template has a variable ``operations`` available\nwhich contains an array of operations.\n\n.. note::\n\n    Always include a trailing comma for each entry you add to the index. Doctum\n    will take care of ensuring that trailing commas are handled properly.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcode-lts%2Fdoctum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcode-lts%2Fdoctum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcode-lts%2Fdoctum/lists"}