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.
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" )
1516load ("@bazel_skylib//rules:diff_test.bzl" , "diff_test" )
1617load ("@bazel_skylib//rules:run_binary.bzl" , "run_binary" )
1718load ("@io_bazel_stardoc//stardoc:stardoc.bzl" , "stardoc" )
19+ load ("@com_google_protobuf//:protobuf.bzl" , "py_proto_library" )
1820
1921stardoc (
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
3134stardoc (
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
4246stardoc (
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
8485py_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)
0 commit comments