Skip to content

Commit d9c8939

Browse files
committed
Use Org Mode for hand-written and generated documentation
1 parent 114d6b1 commit d9c8939

15 files changed

Lines changed: 715 additions & 420 deletions

.gitattributes

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2021 Google LLC
1+
# Copyright 2021, 2022 Google LLC
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -20,4 +20,4 @@ WORKSPACE text eol=lf
2020

2121
# We enforce Unix-style line endings for the Stardoc files to address
2222
# https://github.com/bazelbuild/stardoc/issues/110.
23-
/docs/*.md text eol=lf
23+
/docs/*.org text eol=lf
File renamed without changes.

build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def docs(self) -> None:
143143
"""Build the generated documentation files."""
144144
output = self._run(
145145
[str(self._bazel_program), 'query', '--output=label',
146-
r'filter("\.md\.generated$", kind("generated file", //...:*))'],
146+
r'filter("\.org\.generated$", kind("generated file", //...:*))'],
147147
capture_stdout=True)
148148
targets = output.splitlines()
149149
bazel_bin = self._cwd / 'bazel-bin'

docs/BUILD

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2020, 2021 Google LLC
1+
# Copyright 2020, 2021, 2022 Google LLC
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -12,13 +12,16 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
1516
load("@bazel_skylib//rules:diff_test.bzl", "diff_test")
1617
load("@bazel_skylib//rules:run_binary.bzl", "run_binary")
1718
load("@io_bazel_stardoc//stardoc:stardoc.bzl", "stardoc")
19+
load("@com_google_protobuf//:protobuf.bzl", "py_proto_library")
1820

1921
stardoc(
2022
name = "elisp_doc",
21-
out = "elisp_doc.md",
23+
out = "elisp_doc.bin",
24+
format = "proto",
2225
input = "//elisp:defs.bzl",
2326
deps = [
2427
"//elisp:util_bzl",
@@ -30,7 +33,8 @@ stardoc(
3033

3134
stardoc(
3235
name = "emacs_doc",
33-
out = "emacs_doc.md",
36+
out = "emacs_doc.bin",
37+
format = "proto",
3438
input = "//emacs:defs.bzl",
3539
deps = [
3640
"//elisp:builtin_bzl",
@@ -41,7 +45,8 @@ stardoc(
4145

4246
stardoc(
4347
name = "repositories_doc",
44-
out = "repositories_doc.md",
48+
out = "repositories_doc.bin",
49+
format = "proto",
4550
input = "//elisp:repositories.bzl",
4651
deps = ["//elisp:builtin_bzl"],
4752
)
@@ -53,20 +58,16 @@ DOCS = [
5358
]
5459

5560
[
56-
# Bazel (including Stardoc) interprets all files as Latin-1,
57-
# cf. https://docs.bazel.build/versions/4.1.0/build-ref.html#BUILD_files.
58-
# However, our files all use UTF-8, leading to double encoding. Reverse
59-
# that effect here.
6061
run_binary(
61-
name = "reencode_" + doc,
62-
srcs = [doc + "_doc.md"],
63-
outs = [doc + ".md.generated"],
62+
name = "gen_" + doc,
63+
srcs = [doc + "_doc.bin"],
64+
outs = [doc + ".org.generated"],
6465
args = [
6566
"--",
66-
"$(location :{}_doc.md)".format(doc),
67-
"$(location :{}.md.generated)".format(doc),
67+
"$(location :{}_doc.bin)".format(doc),
68+
"$(location :{}.org.generated)".format(doc),
6869
],
69-
tool = ":reencode",
70+
tool = ":org",
7071
)
7172
for doc in DOCS
7273
]
@@ -75,15 +76,30 @@ DOCS = [
7576
diff_test(
7677
name = doc + "_test",
7778
size = "small",
78-
file1 = doc + ".md",
79-
file2 = doc + ".md.generated",
79+
file1 = doc + ".org",
80+
file2 = doc + ".org.generated",
8081
)
8182
for doc in DOCS
8283
]
8384

8485
py_binary(
85-
name = "reencode",
86-
srcs = ["reencode.py"],
86+
name = "org",
87+
srcs = ["org.py"],
8788
python_version = "PY3",
8889
srcs_version = "PY3",
90+
tags = ["no-pytype"], # FIXME
91+
deps = [":stardoc_output_py_proto"],
92+
)
93+
94+
py_proto_library(
95+
name = "stardoc_output_py_proto",
96+
srcs = [":stardoc_output.proto"],
97+
srcs_version = "PY3",
98+
tags = ["no-python-check"],
99+
)
100+
101+
copy_file(
102+
name = "copy_stardoc_output_proto",
103+
src = "@io_bazel_stardoc//stardoc/proto:stardoc_output.proto",
104+
out = "stardoc_output.proto",
89105
)

docs/elisp.md

Lines changed: 0 additions & 224 deletions
This file was deleted.

0 commit comments

Comments
 (0)