Skip to content

Commit 38910b8

Browse files
ylecornecmergify-bot
authored and
mergify-bot
committed
fix absolute paths in api doc
1 parent 8a8e107 commit 38910b8

File tree

5 files changed

+49
-8
lines changed

5 files changed

+49
-8
lines changed

docs/BUILD.bazel

+31-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
load("@io_bazel_stardoc//stardoc:stardoc.bzl", "stardoc")
22
load("@rules_python//python:defs.bzl", "py_binary")
3+
load("@rules_haskell//docs/pandoc:pandoc.bzl", "set_site_end_location")
4+
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
5+
6+
bool_flag(
7+
name = "render_dev_website",
8+
build_setting_default = False,
9+
)
10+
11+
config_setting(
12+
name = "dev_website_config",
13+
flag_values = {
14+
"render_dev_website": "True",
15+
},
16+
)
17+
18+
set_site_end_location(
19+
name = "set_site_end_location",
20+
site_end_location = select({
21+
":dev_website_config": "/api",
22+
"//conditions:default": "",
23+
}),
24+
)
325

426
libraries = [
527
"defs",
@@ -49,6 +71,7 @@ libraries = [
4971
outs = ["haskell/%s.html" % lib],
5072
cmd = """\
5173
$(execpath //docs/pandoc) \
74+
-V path_prefix=$(SITE_END_LOCATION)\
5275
-f markdown \
5376
-t html \
5477
-s \
@@ -57,8 +80,9 @@ $(execpath //docs/pandoc) \
5780
--toc \
5881
--toc-depth=2 \
5982
-o $(OUTS) \
60-
$(execpath :%s_md)
61-
""" % lib,
83+
$(execpath :{}_md)
84+
""".format(lib),
85+
toolchains = [":set_site_end_location"],
6286
tools = ["//docs/pandoc"],
6387
),
6488
)
@@ -90,6 +114,7 @@ genrule(
90114
outs = ["nav.html"],
91115
cmd = """\
92116
$(execpath //docs/pandoc) \
117+
-V path_prefix=$(SITE_END_LOCATION)\
93118
-f markdown \
94119
-t html \
95120
-s \
@@ -99,6 +124,7 @@ $(execpath //docs/pandoc) \
99124
--metadata-file=$(execpath :metadata) \
100125
<<<""
101126
""",
127+
toolchains = [":set_site_end_location"],
102128
tools = ["//docs/pandoc"],
103129
)
104130

@@ -115,6 +141,7 @@ genrule(
115141
cmd = """\
116142
# Render overview page body.
117143
$(execpath //docs/pandoc) \
144+
-V path_prefix=$(SITE_END_LOCATION)\
118145
-f markdown \
119146
-t html \
120147
-s \
@@ -125,6 +152,7 @@ $(execpath //docs/pandoc) \
125152
<<<""
126153
# Render full overview page including navigation sidebar.
127154
$(execpath //docs/pandoc) \
155+
-V path_prefix=$(SITE_END_LOCATION)\
128156
-f html \
129157
-t html \
130158
-s \
@@ -137,6 +165,7 @@ $(execpath //docs/pandoc) \
137165
--metadata-file=$(execpath :metadata) \
138166
index_body.html
139167
""",
168+
toolchains = [":set_site_end_location"],
140169
tools = ["//docs/pandoc"],
141170
)
142171

docs/pandoc/pandoc.bzl

+12
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,15 @@ pandoc_toolchain(
7676
""",
7777
**kwargs
7878
)
79+
80+
def _set_site_end_location(ctx):
81+
return [
82+
platform_common.TemplateVariableInfo({
83+
"SITE_END_LOCATION": ctx.attr.site_end_location,
84+
}),
85+
]
86+
87+
set_site_end_location = rule(
88+
implementation = _set_site_end_location,
89+
attrs = {"site_end_location": attr.string()},
90+
)

docs/templates/index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
$-- Translation of Skydoc Jinja templates to pandoc
1616
$-- https://github.com/bazelbuild/skydoc/blob/b8a32e0/skydoc/templates
1717
$for(module)$
18-
<h2><a href="/haskell/$module.name$.html" id="$module.name$">$module.summary$</a></h2>
18+
<h2><a href="$path_prefix$/haskell/$module.name$.html" id="$module.name$">$module.summary$</a></h2>
1919
<table class="overview-table">
2020
<colgroup>
2121
<col class="col-name" />
@@ -25,7 +25,7 @@ <h2><a href="/haskell/$module.name$.html" id="$module.name$">$module.summary$</a
2525
$for(module.symbol)$
2626
<tr>
2727
<td>
28-
<a href="/haskell/$module.name$.html#$module.symbol.name$">
28+
<a href="$path_prefix$/haskell/$module.name$.html#$module.symbol.name$">
2929
<code>$module.symbol.name$</code>
3030
</a>
3131
</td>

docs/templates/nav.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
<span class="mdl-layout-title">Bazel</span>
1919
<nav class="drawer-nav">
2020
<ul class="drawer-nav">
21-
<li><a href="/index.html">Overview</a></li>
21+
<li><a href="$path_prefix$/index.html">Overview</a></li>
2222
$for(module)$
2323
<li>
24-
<a href="/haskell/$module.name$.html">$module.summary$</a>
24+
<a href="$path_prefix$/haskell/$module.name$.html">$module.summary$</a>
2525
<ul>
2626
$for(module.symbol)$
2727
<li>
28-
<a href="/haskell/$module.name$.html#$module.symbol.name$" $if(module.symbol.summary)$title="$module.symbol.summary$"$endif$>
28+
<a href="$path_prefix$/haskell/$module.name$.html#$module.symbol.name$" $if(module.symbol.summary)$title="$module.symbol.summary$"$endif$>
2929
$module.symbol.name$
3030
</a>
3131
</li>

serve-docs.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ finish() {
1616

1717
trap finish EXIT
1818

19-
bazel build //docs:api_html
19+
bazel build //docs:api_html --//docs:render_dev_website
2020
mkdir "$SCRATCH/api"
2121
unzip -d "$SCRATCH/api" bazel-bin/docs/api_html-stardoc.zip
2222

0 commit comments

Comments
 (0)