Skip to content
This repository was archived by the owner on Aug 28, 2019. It is now read-only.

Commit ac00fca

Browse files
committed
Flatten genindex to not group names.
Also better width in the tables.
1 parent 9d04005 commit ac00fca

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

docs/_templates/genindex.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@
1717
key = key.substr(12); // discord.ext.
1818
}
1919

20-
if(el.textContent.endsWith('method)') || el.textContent.indexOf('()') !== -1) {
20+
if(el.textContent.indexOf('()') !== -1) {
2121
key = key + '()'
2222
}
2323
el.textContent = key;
2424
}
25+
document.querySelectorAll("td").forEach(el => el.style.width = 'auto');
2526
</script>
2627
{% endblock %}

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3232
# ones.
3333
extensions = [
34+
'builder',
3435
'sphinx.ext.autodoc',
3536
'sphinx.ext.extlinks',
3637
'sphinx.ext.intersphinx',

docs/extensions/builder.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
from sphinx.builders.html import StandaloneHTMLBuilder
2+
from sphinx.environment.adapters.indexentries import IndexEntries
3+
4+
class DPYStandaloneHTMLBuilder(StandaloneHTMLBuilder):
5+
# This is mostly copy pasted from Sphinx.
6+
def write_genindex(self) -> None:
7+
# the total count of lines for each index letter, used to distribute
8+
# the entries into two columns
9+
genindex = IndexEntries(self.env).create_index(self, group_entries=False)
10+
indexcounts = []
11+
for _k, entries in genindex:
12+
indexcounts.append(sum(1 + len(subitems)
13+
for _, (_, subitems, _) in entries))
14+
15+
genindexcontext = {
16+
'genindexentries': genindex,
17+
'genindexcounts': indexcounts,
18+
'split_index': self.config.html_split_index,
19+
}
20+
21+
if self.config.html_split_index:
22+
self.handle_page('genindex', genindexcontext,
23+
'genindex-split.html')
24+
self.handle_page('genindex-all', genindexcontext,
25+
'genindex.html')
26+
for (key, entries), count in zip(genindex, indexcounts):
27+
ctx = {'key': key, 'entries': entries, 'count': count,
28+
'genindexentries': genindex}
29+
self.handle_page('genindex-' + key, ctx,
30+
'genindex-single.html')
31+
else:
32+
self.handle_page('genindex', genindexcontext, 'genindex.html')
33+
34+
def get_builder(app):
35+
"""This is necessary because RTD injects their own for some reason."""
36+
try:
37+
original = app.registry.builders['readthedocs']
38+
except KeyError:
39+
return DPYStandaloneHTMLBuilder
40+
else:
41+
injected_mro = tuple(base if base is not StandaloneHTMLBuilder else DPYStandaloneHTMLBuilder
42+
for base in original.mro()[1:])
43+
return type(original.__name__, injected_mro, {'name': 'readthedocs'})
44+
45+
def setup(app):
46+
app.add_builder(get_builder(app), override=True)

0 commit comments

Comments
 (0)