Sphinx conf.py - 将附加文档特定数据传递给每个 PDF,例如文档标题和作者

发布于 2025-01-17 06:23:31 字数 1607 浏览 2 评论 0原文

我的目标是在自动化过程中使用 Sphinx 创建一组 PDF 文档,但我发现使用 conf.py 中的 Latex_documents 元组可以传递的文档特定信息太有限。我将尝试解释到目前为止我所尝试的内容,这如何限制我想做的事情以及一个示例“假设”解决方案。

到目前为止我已经尝试过的内容:

如上所述,我的目标是创建一组文档,并且我的配置使用单个conf.py。要从单个 conf.py 创建一组文档,“latex_documents”关键字引用文档特定信息。它使用元组列表来实现这一点,每个文档一个元组。例如,该元组包含对每个特定文档的索引文件、作者和标题的引用(索引文件然后引用相关的重构文本等)。

这很棒,因为我可以更新每个标题页上文档的特定作者的名称和标题,并且可以从索引中获取文本正文。

下面是一个单一元组的示例,代表一个文档,与 Latex_documents 关键字相关联:

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
#  author, documentclass [howto, manual, or own class]).
latex_documents = [('path/to/index', 'document_name', 'my document title', 'JSt', 'howto')]

在此示例中,Sphinx 可以使作者姓名 JSt 出现在标题页上。

有什么限制?

但是,如果我们还想自动向每个文档的标题页传递更多信息:执行摘要、审阅者姓名、批准者姓名、文档编号等等,该怎么办?这些信息与作者一样,是特定于文档的,将放置在通用标题页和/或页眉和页脚上(因此也不能放入重构文本或降价输入中)。

假设解决方案

如果 Latex_documents 输入不是/不是规定性的,示例解决方案可能如下。

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
#  author, reviewer, approver, document number, documentclass [howto, manual, or own class]).
latex_documents = [('path/to/index', 'document_name', 'my document title', 'JSt', 'ABc', 'ZYx', 'DOC007' 'howto')]

通过在标题页中调用如下内容:

\@author
\@reviewer
\@approver
\@docnum

将在 tex.txt 中创建类似以下内容的内容。

\author{JSt}
\reviewer{ABc}
\approver{ZYx}
\docnum{DOC007}

有没有人有关于以与作者相同的方式将附加文档特定信息传递到文档的标题页、页眉和页脚的建议?

提前致谢。

My goal is to create a set of PDF documents using Sphinx in an automated process, except I've found I'm too limited in what document specific information I can pass using latex_documents tuple in conf.py. I'll try to explain what I've tried so far, how this is limits what I would like to do and an example "hypothetical" solution.

What I've tried so far:

As stated, my goal is to create a set of documents and my configuration uses a single conf.py. To create a set of documents from a single conf.py, the "latex_documents" keyword references document specific information. It does so using a list of tuples, one tuple per document. This tuple, for example, contains reference to each specific document's index file, author and title (the index file then references the relevant restructured text etc).

This is great because I can update the name of the document's specific author and title on each title page, and the body of the text is picked up from the index.

Here is an example of a single tuple, representing one document, associated with the latex_documents keyword:

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
#  author, documentclass [howto, manual, or own class]).
latex_documents = [('path/to/index', 'document_name', 'my document title', 'JSt', 'howto')]

In this example, Sphinx can make JSt, the author's name, appear on the title page.

What is the limitation?

But what if we also wanted to pass to each document's title page, automatically, more information: an executive summary, reviewer name, approver name, document number and even more. This is information, like author, is document specific and will be placed on the generic title page and / or headers and footers (and therefore cannot be put in the restructuredtext or markdown input either).

Hypothetical solution

An example solution, if latex_documents input wasn't / isn't prescriptive, could be as follows.

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
#  author, reviewer, approver, document number, documentclass [howto, manual, or own class]).
latex_documents = [('path/to/index', 'document_name', 'my document title', 'JSt', 'ABc', 'ZYx', 'DOC007' 'howto')]

Which by calling in the title page as somthing like:

\@author
\@reviewer
\@approver
\@docnum

Will create something like the following in the tex.

\author{JSt}
\reviewer{ABc}
\approver{ZYx}
\docnum{DOC007}

Does anyone have advice on passing additional document specific information to the title page, headers and footers of a document in the same way author is?

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文