Phpdocumentor looks for custom templates in vendor directory
Asked Answered
M

2

16

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.

Mystic answered 21/1, 2016 at 10:18 Comment(2)
First, what's your question? Second, post some code.Calabar
@Calabar my question is how to force documentor to get the template from specific place, not from the vendor dir, all the code that is involved is this xml with configuration.Mystic
E
1

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.

Eureetloir answered 28/9, 2017 at 8:42 Comment(0)
H
0

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"
Halve answered 1/6, 2016 at 6:31 Comment(2)
I don't have a possibility to test this right now but I'll sure do it tomorrow morning. From what I remember though, template path is looked up correctly, the problem was with paths that are defined in the template. But as I said, I'll test it ASAP.Mystic
I honestly haven't had the ability to test this either... it's what I vaguely remember from a while back combined with the docs in the linkHalve

© 2022 - 2024 — McMap. All rights reserved.