Adam
Adam

Reputation: 873

Phpdocumentor looks for custom templates in vendor directory

I need to create custom template for PhpDocumentor. The problem is that paths defined in the template.xml, even when specified as absolute ones, are not resolved correctly. PhpDocumentor looks for them in the vendor directory.

<template>
    <author>Code Mine</author>
    <email>[email protected]</email>
    <description>Template for Confluence API</description>
    <version>1.0.0</version>
    <transformations>
        <transformation writer="twig" source="./index.html.twig" artifact="index.html"/>
        <transformation query="indexes.namespaces" writer="twig" source="./namespace.html.twig" />
        <transformation query="indexes.classes" writer="twig" source="./class.html.twig" />
    </transformations>
</template>

Despite fact that twig templates are located in path to which xml refers, I'm getting error that files don't exist.

EDIT:

I have also tried with setting up all configuration details in phpdoc.xml in hope that paths will be considered relative to configuration file but with no luck.

Upvotes: 16

Views: 890

Answers (2)

TheStoryCoder
TheStoryCoder

Reputation: 3640

If you specify a custom template with --template="..." it will (for some strange reason) copy that entire template into the vendor folder together with the original templates, and therefore the path structure in template.xml needs to remain the same. You only need to change eg. templates/clean/ to templates/yourtemplatename/.

I have an issue with caching though. I can't get it to reread my template every time. It has cached it somewhere and I can't for the life of me figure out where. Documentation is really bad and source is worse.

Update: Finally figured out that it cached my template in the temp folder of my computer. For Windows eg.: c:\Users\<username>\AppData\Local\Temp\phpdoc-twig-cache\. So I just delete that entire folder.

Upvotes: 1

edhurtig
edhurtig

Reputation: 2361

Correct me if I'm wrong but it seems like you can just pass a file path on the CLI

https://www.phpdoc.org/docs/latest/getting-started/changing-the-look-and-feel.html

Using a custom template When you have a company or project-branded template you can also use that with phpDocumentor by providing the location of your template’s folder:

$ phpdoc -d "./src" -t "./docs/api" --template="data/templates/my_template"

you may need to back out of the vendors directory with a few ..'s like so

--template="../../data/templates/my_template"

or pass an absolute path

--template="/var/scratch/foo/data/templates/my_template"

Upvotes: 0

Related Questions