我已经做了一些编写程序的实验,这些程序同时也是有效的文档,可以通过例如 Github 呈现为自述文件——这确保了代码片段是最新的和有效的——并且在 Markdown 中有一些非常有趣的发现。不幸的是,这种格式不支持自动生成的目录,所以我们研究了 AsciiDoc,它支持。
我设法复制了一个示例:toc: macro(以便能够将其放在开头摘要之后),然后继续使其成为有效的 Java,这实际上意味着您必须使用/*字符开始文件,但随后我无法制作表格的内容不再出现。
片段开始于:
= Asciidoctor PDF Theming Guide
Dan Allen <https://github.com/mojavelinux[@mojavelinux]>
// Settings:
:idprefix:
:idseparator: -
:toc: macro
:experimental:
ifndef::env-github[:icons: font]
ifdef::env-github[]
:outfilesuffix: .adoc
:!toc-title:
:caution-caption: :fire:
:important-caption: :exclamation:
:note-caption: :paperclip:
:tip-caption: :bulb:
:warning-caption: :warning:
endif::[]
:window: _blank
// Aliases:
:conum-guard-yaml: #
ifndef::icons[:conum-guard-yaml: # #]
ifdef::backend-pdf[:conum-guard-yaml: # #]
:url-fontforge: https://fontforge.github.io/en-US/
:url-fontforge-scripting: https://fontforge.github.io/en-US/documentation/scripting/
:url-prawn: http://prawnpdf.org
////
Topics remaining to document:
* line height and line height length (and what that all means)
* title page layout / title page images (logo & background)
////
[.lead]
The theming system in Asciidoctor PDF is used to control the layout and styling of the PDF file
... blurb removed ...
/* (Experiment with asciidoc)
= Dagger 2 Hello World
// (Important: As an experiment Main.java is also a valid markdown file copied unmodified to README.md, so only edit Main.java)
This project is a single file Hello World Dagger-2 Maven project for
Java 8 and later, while also being its own documentation written in AsciiDoc.
toc::[]
我的直觉是,只有当文件以设置和配置 AsciiDoc 解析的行开头时,TOC 才会按预期工作。如果在配置位之前生成任何输出(如 Java 注释),则 TOC 为空。
因此,我想知道我应该如何正确地做到这一点。我想要的只是toc::[]文件中的一个功能宏/*