Skip to content

Commit 0f6e869

Browse files
committed
Add basic support for tagging text in the spec
This adds three things: 1. Custom CSS to add a subtle dotted underline on hover to any element with an ID starting with `manual__`. 2. An example tag `manual__x0_is_zero`, tagging the text that specifies that x0 is hardwired to 0. 3. A way of extracting the text of the tags into JSON. This just adds a single tag as an exmaple, but the intention is that such tags would be added throughout the spec, allowing coverage, test plans, tests, documentation, etc. to all link to specific parts of the spec.
1 parent 5a98aa0 commit 0f6e869

File tree

5 files changed

+38
-4
lines changed

5 files changed

+38
-4
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule "docs-resources"]
22
path = docs-resources
3-
url = https://github.com/riscv/docs-resources
3+
url = https://github.com/Timmmm/docs-resources

Makefile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,16 @@ BUILD_DIR := build
9393
DOCS_PDF := $(addprefix $(BUILD_DIR)/, $(addsuffix .pdf, $(DOCS)))
9494
DOCS_HTML := $(addprefix $(BUILD_DIR)/, $(addsuffix .html, $(DOCS)))
9595
DOCS_EPUB := $(addprefix $(BUILD_DIR)/, $(addsuffix .epub, $(DOCS)))
96+
DOCS_TAGS := $(addprefix $(BUILD_DIR)/, $(addsuffix .tags.json, $(DOCS)))
9697

9798
ENV := LANG=C.utf8
9899
XTRA_ADOC_OPTS :=
100+
99101
ASCIIDOCTOR_PDF := $(ENV) asciidoctor-pdf
100102
ASCIIDOCTOR_HTML := $(ENV) asciidoctor
101103
ASCIIDOCTOR_EPUB := $(ENV) asciidoctor-epub3
104+
ASCIIDOCTOR_TAGS := $(ENV) asciidoctor --backend tags --require=./docs-resources/converters/tags.rb
105+
102106
OPTIONS := --trace \
103107
-a compress \
104108
-a mathematical-format=svg \
@@ -107,6 +111,8 @@ OPTIONS := --trace \
107111
$(WATERMARK_OPT) \
108112
-a revnumber='$(DATE)' \
109113
-a revremark='$(RELEASE_DESCRIPTION)' \
114+
-a docinfo=shared \
115+
-a tags-prefix=manual__ \
110116
$(XTRA_ADOC_OPTS) \
111117
-D build \
112118
--failure-level=ERROR
@@ -116,7 +122,7 @@ REQUIRES := --require=asciidoctor-bibtex \
116122
--require=asciidoctor-mathematical \
117123
--require=asciidoctor-sail
118124

119-
.PHONY: all build clean build-container build-no-container build-docs build-pdf build-html build-epub submodule-check
125+
.PHONY: all build clean build-container build-no-container build-docs build-pdf build-html build-epub build-tags submodule-check
120126

121127
all: build
122128

@@ -132,6 +138,7 @@ build-docs: $(DOCS_PDF) $(DOCS_HTML) $(DOCS_EPUB)
132138
build-pdf: $(DOCS_PDF)
133139
build-html: $(DOCS_HTML)
134140
build-epub: $(DOCS_EPUB)
141+
build-tags: $(DOCS_TAGS)
135142

136143
ALL_SRCS := $(shell git ls-files $(SRC_DIR))
137144

@@ -150,6 +157,11 @@ $(BUILD_DIR)/%.epub: $(SRC_DIR)/%.adoc $(ALL_SRCS)
150157
$(DOCKER_CMD) $(DOCKER_QUOTE) $(ASCIIDOCTOR_EPUB) $(OPTIONS) $(REQUIRES) $< $(DOCKER_QUOTE)
151158
$(WORKDIR_TEARDOWN)
152159

160+
$(BUILD_DIR)/%.tags.json: $(SRC_DIR)/%.adoc $(ALL_SRCS) docs-resources/converters/tags.rb
161+
$(WORKDIR_SETUP)
162+
$(DOCKER_CMD) $(DOCKER_QUOTE) $(ASCIIDOCTOR_TAGS) $(OPTIONS) $(REQUIRES) $< $(DOCKER_QUOTE)
163+
$(WORKDIR_TEARDOWN)
164+
153165
build: submodule-check
154166
@echo "Checking if Docker is available..."
155167
@if command -v docker >/dev/null 2>&1 ; then \

docs-resources

src/docinfo.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<style>
2+
/*
3+
Any ID starting with 'manual__' is a snippet of specification text
4+
that has been specifically tagged to allow referencing it robustly,
5+
for use cases such as:
6+
7+
* Linking coverage, tests plans, tests, assertions etc. to parts of
8+
the spec that they cover.
9+
* Detecting when parts of the spec change. You can extract these
10+
snippets via Asciidoc's docbook output and parsing the XML.
11+
* Linking documentation (e.g. the implementation defined parameter list)
12+
to the spec.
13+
14+
This adds a subtle decoration to make it easier to find tagged text.
15+
*/
16+
[id^="manual_"]:hover {
17+
text-decoration: underline;
18+
text-decoration-style: dotted;
19+
text-decoration-color: gray;
20+
}
21+
</style>

src/rv32.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ Most of the commentary for RV32I also applies to the RV64I base.
4040

4141
<<gprs>> shows the unprivileged state for the base
4242
integer ISA. For RV32I, the 32 `x` registers are each 32 bits wide,
43-
i.e., `XLEN=32`. Register `x0` is hardwired with all bits equal to 0.
43+
i.e., `XLEN=32`.
44+
[#manual__x0_is_zero]#Register `x0` is hardwired with all bits equal to 0.#
4445
General purpose registers `x1-x31` hold values that various
4546
instructions interpret as a collection of Boolean values, or as two's
4647
complement signed binary integers or unsigned binary integers.

0 commit comments

Comments
 (0)