Skip to content

Commit 65e7b2c

Browse files
committed
Using caption with different toc sections instead of JS/CSS hack.
This fits within the Sphinx construct and would allow our docs to be built on readthedocs.org.
1 parent 2928bfc commit 65e7b2c

File tree

6 files changed

+54
-18
lines changed

6 files changed

+54
-18
lines changed

docs/_static/css/main.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,18 @@ h2 .headerlink:hover {
862862
margin-top: 2em;
863863
}
864864

865+
.side-nav > ul > li.toctree-l1 {
866+
padding-left: 2em;
867+
}
868+
869+
p.caption {
870+
padding-left: 2em;
871+
}
872+
873+
span.caption-text {
874+
font-weight: bold;
875+
}
876+
865877
.external-links img {
866878
margin-right: 0.3em;
867879
opacity: 0.3;

docs/_static/js/main.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,6 @@ $('.headerlink').parent().each(function() {
1313
);
1414
});
1515

16-
$('.side-nav').children('ul:nth-child(2)').children().each(function() {
17-
var itemName = $(this).text();
18-
if (itemName !== 'Datastore' &&
19-
itemName !== 'Storage' &&
20-
itemName !== 'Pub/Sub' &&
21-
itemName !== 'BigQuery') {
22-
$(this).css('padding-left','2em');
23-
}
24-
});
25-
2616
var apiQsSection;
2717
// don't even ask me why
2818
if ($('#cloud-datastore-in-10-seconds').length)

docs/_templates/layout.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ <h1 class="page-title">Python</h1>
127127
{% block body %} {% endblock %}
128128
</section><!-- end of .content -->
129129
<nav class="side-nav">
130-
<ul><li><a href="{{ pathto('index') }}">gcloud</a></li></ul>
131130
{{ toctree(includehidden=True, maxdepth=1, titles_only=True) }}
132131
<ul class="external-links">
133132
<li>

docs/conf.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,17 @@
1111
# All configuration values have a default; values that are commented out
1212
# serve to show the default.
1313

14+
import os
1415
from pkg_resources import get_distribution
15-
import sys, os
16+
import sys
1617
import urllib
1718

19+
import sphinx_rtd_theme
20+
21+
22+
ON_READ_THE_DOCS = os.environ.get('READTHEDOCS', None) == 'True'
23+
LOCAL_READ_THE_DOCS = os.environ.get('LOCAL_RTD', None) == 'True'
24+
1825
# If extensions (or modules to document with autodoc) are in another directory,
1926
# add these directories to sys.path here. If the directory is relative to the
2027
# documentation root, use os.path.abspath to make it absolute, like shown here.
@@ -36,7 +43,10 @@
3643
]
3744

3845
# Add any paths that contain templates here, relative to this directory.
39-
templates_path = ['_templates']
46+
if ON_READ_THE_DOCS or LOCAL_READ_THE_DOCS:
47+
templates_path = []
48+
else:
49+
templates_path = ['_templates']
4050

4151
# The suffix of source filenames.
4252
source_suffix = '.rst'
@@ -100,10 +110,10 @@
100110

101111
html_theme = 'classic'
102112

103-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
104-
if on_rtd:
105-
html_style = 'default.css'
106-
else:
113+
if LOCAL_READ_THE_DOCS:
114+
html_theme = 'sphinx_rtd_theme'
115+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
116+
elif not ON_READ_THE_DOCS:
107117
html_style = 'css/main.css'
108118

109119
# Theme options are theme-specific and customize the look and feel of a theme

docs/index.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,48 @@
11
.. toctree::
22
:maxdepth: 0
33
:hidden:
4+
:caption: gcloud
45

56
gcloud-api
7+
8+
.. toctree::
9+
:maxdepth: 0
10+
:hidden:
11+
:caption: Datastore
12+
613
datastore-overview
714
datastore-client
815
datastore-entities
916
datastore-keys
1017
datastore-queries
1118
datastore-transactions
1219
datastore-batches
20+
21+
.. toctree::
22+
:maxdepth: 0
23+
:hidden:
24+
:caption: Storage
25+
1326
storage-api
1427
storage-blobs
1528
storage-buckets
1629
storage-acl
30+
31+
.. toctree::
32+
:maxdepth: 0
33+
:hidden:
34+
:caption: Pub/Sub
35+
1736
pubsub-api
1837
pubsub-usage
1938
pubsub-topic
2039
pubsub-subscription
40+
41+
.. toctree::
42+
:maxdepth: 0
43+
:hidden:
44+
:caption: BigQuery
45+
2146
bigquery-usage
2247

2348

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ commands =
4040
sphinx-build -W -b html -d docs/_build/doctrees docs docs/_build/html
4141
deps =
4242
Sphinx
43-
passenv = {[testenv:system-tests]passenv} SPHINX_RELEASE
43+
passenv = {[testenv:system-tests]passenv} SPHINX_RELEASE READTHEDOCS LOCAL_RTD
4444

4545
[pep8]
4646
exclude = gcloud/datastore/_datastore_v1_pb2.py,docs/conf.py

0 commit comments

Comments
 (0)