我需要为PhpDocumentor创建自定义模板。问题是在template.xml
中定义的路径,即使指定为绝对路径,也不能正确解析。PhpDocumentor在供应商目录中查找它们。
<template>
<author>Code Mine</author>
<email>office@code-mine.com</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>
尽管twig模板位于xml引用的路径中,但我收到了文件不存在的错误。
编辑:
我还尝试在phpdoc.xml
中设置所有的配置细节,希望路径将被认为是相对于配置文件的,但没有成功。
发布于 2017-09-28 16:42:19
如果您使用--template="..."
指定一个自定义模板,它会(出于某种奇怪的原因)将整个模板连同原始模板一起复制到供应商文件夹中,因此template.xml
中的路径结构需要保持不变。你只需要改变一下。templates/clean/
到templates/yourtemplatename/
。
不过,我对缓存有一个问题。我不能让它每次都重读我的模板。它已经把它缓存在某个地方了,我永远也找不到它在哪里。文档真的很糟糕,源代码更糟糕。
更新:终于发现它把我的模板缓存在我电脑的临时文件夹里了。对于Windows,例如:c:\Users\<username>\AppData\Local\Temp\phpdoc-twig-cache\
。所以我删除了整个文件夹。
发布于 2016-06-01 14:31:40
如果我说错了,请纠正我,但您似乎只需在CLI上传递文件路径
https://www.phpdoc.org/docs/latest/getting-started/changing-the-look-and-feel.html
使用自定义模板当您有公司或项目品牌的模板时,您还可以通过提供模板文件夹的位置将其与phpDocumentor一起使用:
$ phpdoc -d "./src" -t "./docs/api" --template="data/templates/my_template"
您可能需要使用一些..
退出供应商目录,如下所示
--template="../../data/templates/my_template"
或传递绝对路径
--template="/var/scratch/foo/data/templates/my_template"
https://stackoverflow.com/questions/34920955
复制相似问题