Skip to content

Commit b902198

Browse files
committed
Group members in API docs
1 parent f148f2b commit b902198

File tree

4 files changed

+51
-1
lines changed

4 files changed

+51
-1
lines changed

docs/_static/css/custom.css

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,46 @@ tt, code, pre {
1818
margin: 0;
1919
padding: 0;
2020
}
21+
22+
/* We instruct sphinx to order members groupwise and use the following css to add headlines.
23+
Notice that while the css differentiates between methods, classmethods and staticmethods,
24+
unfortunately, sphinx groups these all alphabetically as methods which means we only
25+
display them as one "methods" group. */
26+
27+
dl.attribute:before {
28+
content: "Attributes";
29+
}
30+
31+
dl.method:before,
32+
dl.classmethod:before,
33+
dl.staticmethod:before {
34+
content: "Methods";
35+
}
36+
37+
dl.method:before,
38+
dl.attribute:before,
39+
dl.classmethod:before,
40+
dl.staticmethod:before {
41+
background: #e7f2fa;
42+
border-top: solid 3px #6ab0de;
43+
color: #000;
44+
display: inline-block;
45+
font-weight: bold;
46+
margin: 5px 0 10px 0;
47+
padding: 5px;
48+
}
49+
50+
/* Remove method header if a previous element already introduced it */
51+
dl.attribute + dl.attribute:before,
52+
/* We have to treat all these as just "methods" (see comment further above) */
53+
dl.method + dl.method:before,
54+
dl.classmethod + dl.method:before,
55+
dl.staticmethod + dl.method:before,
56+
dl.method + dl.classmethod:before,
57+
dl.classmethod + dl.classmethod:before,
58+
dl.staticmethod + dl.classmethod:before,
59+
dl.method + dl.staticmethod:before,
60+
dl.staticmethod + dl.staticmethod:before,
61+
dl.classmethod + dl.staticmethod:before {
62+
display: none;
63+
}

docs/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
'undoc-members': None,
5151
}
5252

53+
autodoc_member_order = 'groupwise'
54+
autodoc_mock_imports = ["snappy"]
5355

5456
# Add any paths that contain templates here, relative to this directory.
5557
templates_path = ['_templates']

newsfragments/1797.doc.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
Tweak layout of API docs to improve readability
1+
Tweak layout of API docs to improve readability
2+
3+
Group API docs by member (methods, attributes)

newsfragments/794.doc.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
In the API docs display class methods, static methods and methods as one group "methods".
2+
While we ideally wish to separate these, Sphinx keeps them all as one group which we'll
3+
be following until we find a better option.

0 commit comments

Comments
 (0)