[英]How to customize sphinx documentation makefile?
I am wondering if there is anyway to customize the sphinx documentation makefile? 我想知道是否仍然可以自定义sphinx文档的makefile?
What I want to achieve is that each time I do make html
, sphinx will go to certain directory and copy the specific file to my source
directory. 我想要实现的是,每次我
make html
,sphinx都会转到特定目录,并将特定文件复制到我的source
目录。
For example: 例如:
Suppose I have a script called name foo.py
under ~/bar
directory. 假设我在
~/bar
目录下有一个名为name foo.py
的脚本。 I want foo.py
to be copied to ~/docs/source/
directory, which will be referenced by my project.rst
. 我希望将
foo.py
复制到~/docs/source/
目录,这将由我的project.rst
引用。
The reason I want to do this is that I want to keep the script I referenced in the doc to be the latest version and I hate to do copy-paste each time I do make html
. 我要这样做的原因是,我想将文档中引用的脚本保持为最新版本,并且每次执行
make html
时都不想复制粘贴。
I know I can achieve this purpose with a simple shell script. 我知道我可以通过一个简单的shell脚本来实现此目的。 But, I am wondering if I can do it directly through sphinx make file?
但是,我想知道是否可以直接通过sphinx make文件来执行此操作吗?
Thanks much! 非常感谢!
An easy solution is to create a symbolic/hard link ( ln -s path/to/destination path/to/link
, remove the -s
for a hard link). 一个简单的解决方案是创建一个符号/硬链接(
ln -s path/to/destination path/to/link
,删除-s
表示硬链接)。
In your case, ln -s ~/bar/foo.py ~/docs/source/foo.py
will create a link in the ~/docs/source/
directory (always up-to-date because it is just a link to your original file). 在您的情况下,
ln -s ~/bar/foo.py ~/docs/source/foo.py
将在~/docs/source/
目录中创建一个链接(始终是最新的,因为它只是指向您的原始文件)。
For fancier or more complete Makefile rule, have a look this customized sphinx Makefile . 对于更高级或更完整的Makefile规则,请查看此自定义的sphinx Makefile 。 There is plenty of rules that send files over the web or from one directory to another (in my case
~/web-sphinx/.build/html/*
to ~/Public/
). 有很多规则可以将文件通过Web或从一个目录发送到另一个目录(在我的情况下,是
~/web-sphinx/.build/html/*
到~/Public/
)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.