Skip to content

Commit 13aa4b1

Browse files
authored
Make the table of contents collapsed by default (#2364)
1 parent 4c76e96 commit 13aa4b1

File tree

6 files changed

+66
-50
lines changed

6 files changed

+66
-50
lines changed

pep-0249.txt

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ Post-History:
1212
Replaces: 248
1313

1414

15-
`Introduction`_
16-
===============
15+
Introduction
16+
============
1717

1818
This API has been defined to encourage similarity between the Python
1919
modules that are used to access databases. By doing this, we hope to
@@ -35,11 +35,11 @@ encouraged to use this version of the specification as basis for new
3535
interfaces.
3636

3737

38-
`Module Interface`_
39-
===================
38+
Module Interface
39+
=================
4040

41-
`Constructors`_
42-
---------------
41+
Constructors
42+
------------
4343

4444
Access to the database is made available through connection
4545
objects. The module must provide the following constructor for these:
@@ -53,8 +53,8 @@ objects. The module must provide the following constructor for these:
5353
which are database dependent. [1]_
5454

5555

56-
`Globals`_
57-
----------
56+
Globals
57+
-------
5858

5959
These module globals must be defined:
6060

@@ -107,8 +107,8 @@ These module globals must be defined:
107107
============ ==============================================================
108108

109109

110-
`Exceptions`_
111-
-------------
110+
Exceptions
111+
----------
112112

113113
The module should make all error information available through these
114114
exceptions or subclasses thereof:
@@ -220,14 +220,14 @@ This is the exception inheritance layout::
220220

221221
.. _Connection:
222222

223-
`Connection Objects`_
224-
=====================
223+
Connection Objects
224+
==================
225225

226226
Connection objects should respond to the following methods.
227227

228228

229-
`Connection methods`_
230-
---------------------
229+
Connection methods
230+
------------------
231231

232232
.. .close():
233233
.. _Connection.close:
@@ -283,8 +283,8 @@ Connection objects should respond to the following methods.
283283

284284
.. _Cursor:
285285

286-
`Cursor Objects`_
287-
=================
286+
Cursor Objects
287+
==============
288288

289289
These objects represent a database cursor, which is used to manage the
290290
context of a fetch operation. Cursors created from the same connection
@@ -297,8 +297,8 @@ transaction support is implemented (see also the connection's
297297
Cursor Objects should respond to the following methods and attributes.
298298

299299

300-
`Cursor attributes`_
301-
--------------------
300+
Cursor attributes
301+
-----------------
302302

303303
.. _.description:
304304

@@ -344,8 +344,8 @@ Cursor Objects should respond to the following methods and attributes.
344344
latter case to have the object return ``None`` instead of -1.
345345

346346

347-
`Cursor methods`_
348-
-----------------
347+
Cursor methods
348+
--------------
349349

350350
.. _.callproc:
351351
.. _.callproc():
@@ -561,8 +561,8 @@ Cursor Objects should respond to the following methods and attributes.
561561

562562
.. _Type Objects:
563563

564-
`Type Objects and Constructors`_
565-
================================
564+
Type Objects and Constructors
565+
=============================
566566

567567
Many databases need to have the input in a particular format for
568568
binding to an operation's input parameters. For example, if an input
@@ -682,8 +682,8 @@ on input and output.
682682

683683
.. _Implementation Hints:
684684

685-
`Implementation Hints for Module Authors`_
686-
==========================================
685+
Implementation Hints for Module Authors
686+
=======================================
687687

688688
* Date/time objects can be implemented as `Python datetime module
689689
<http://docs.python.org/library/datetime.html>`__ objects (available
@@ -769,8 +769,8 @@ on input and output.
769769
API to create the exception objects.
770770

771771

772-
`Optional DB API Extensions`_
773-
=============================
772+
Optional DB API Extensions
773+
==========================
774774

775775
During the lifetime of DB API 2.0, module authors have often extended
776776
their implementations beyond what is required by this DB API
@@ -934,8 +934,8 @@ Cursor\ `.lastrowid`_
934934
*Warning Message:* "DB-API extension cursor.lastrowid used"
935935

936936

937-
`Optional Error Handling Extensions`_
938-
=====================================
937+
Optional Error Handling Extensions
938+
==================================
939939

940940
The core DB API specification only introduces a set of exceptions
941941
which can be raised to report errors to the user. In some cases,
@@ -981,8 +981,8 @@ Cursors should inherit the ``.errorhandler`` setting from their
981981
connection objects at cursor creation time.
982982

983983

984-
`Optional Two-Phase Commit Extensions`_
985-
=======================================
984+
Optional Two-Phase Commit Extensions
985+
====================================
986986

987987
Many databases have support for two-phase commit (TPC) which allows
988988
managing transactions across multiple database connections and other
@@ -994,8 +994,8 @@ API should be implemented. NotSupportedError_ should be raised, if the
994994
database backend support for two-phase commit can only be checked at
995995
run-time.
996996

997-
`TPC Transaction IDs`_
998-
----------------------
997+
TPC Transaction IDs
998+
-------------------
999999

10001000
As many databases follow the XA specification, transaction IDs are
10011001
formed from three components:
@@ -1034,8 +1034,8 @@ Transaction IDs are created with the `.xid()`_ Connection method:
10341034
represent transaction IDs with tuples rather than a custom object.
10351035

10361036

1037-
`TPC Connection Methods`_
1038-
-------------------------
1037+
TPC Connection Methods
1038+
----------------------
10391039

10401040
.. _.tpc_*:
10411041
.. _.tpc_*():
@@ -1117,8 +1117,8 @@ Transaction IDs are created with the `.xid()`_ Connection method:
11171117

11181118

11191119

1120-
`Frequently Asked Questions`_
1121-
=============================
1120+
Frequently Asked Questions
1121+
==========================
11221122

11231123
The database SIG often sees reoccurring questions about the DB API
11241124
specification. This section covers some of the issues people sometimes
@@ -1153,8 +1153,8 @@ between databases and makes writing portable code impossible.
11531153

11541154

11551155

1156-
`Major Changes from Version 1.0 to Version 2.0`_
1157-
================================================
1156+
Major Changes from Version 1.0 to Version 2.0
1157+
=============================================
11581158

11591159
The Python Database API 2.0 introduces a few major changes compared to
11601160
the 1.0 version. Because some of these changes will cause existing DB
@@ -1197,8 +1197,8 @@ Post-publishing additions to the DB API 2.0 specification:
11971197
functionality were specified.
11981198

11991199

1200-
`Open Issues`_
1201-
==============
1200+
Open Issues
1201+
===========
12021202

12031203
Although the version 2.0 specification clarifies a lot of questions
12041204
that were left open in the 1.0 version, there are still some remaining
@@ -1213,8 +1213,8 @@ issues which should be addressed in future versions:
12131213

12141214

12151215

1216-
`Footnotes`_
1217-
============
1216+
Footnotes
1217+
=========
12181218

12191219
.. [1] As a guideline the connection constructor parameters should be
12201220
implemented as keyword parameters for more intuitive use and
@@ -1298,8 +1298,8 @@ issues which should be addressed in future versions:
12981298
of the ``.rowcount`` attribute.
12991299

13001300

1301-
`Acknowledgements`_
1302-
===================
1301+
Acknowledgements
1302+
================
13031303

13041304
Many thanks go to Andrew Kuchling who converted the Python Database
13051305
API Specification 2.0 from the original HTML format into the PEP
@@ -1312,7 +1312,7 @@ Many thanks to Daniele Varrazzo for converting the specification from
13121312
text PEP format to ReST PEP format, which allows linking to various
13131313
parts.
13141314

1315-
`Copyright`_
1316-
============
1315+
Copyright
1316+
=========
13171317

13181318
This document has been placed in the Public Domain.

pep-0512.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,8 +465,8 @@ Work for this is being tracked at
465465
https://github.com/python/core-workflow/issues/7.
466466

467467

468-
Create https://git.python.org
469-
'''''''''''''''''''''''''''''
468+
Create ``https://git.python.org``
469+
'''''''''''''''''''''''''''''''''
470470

471471
Just as hg.python.org [#h.p.o]_ currently points to the Mercurial
472472
repository for Python, git.python.org should do the equivalent for

pep_sphinx_extensions/pep_processor/html/pep_html_builder.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def get_doc_context(self, docname: str, body: str, _metatags: str) -> dict:
3838
toc_tree = self.env.tocs[docname].deepcopy()
3939
if len(toc_tree[0]) > 1:
4040
toc_tree = toc_tree[0][1] # don't include document title
41+
del toc_tree[0] # remove contents node
4142
for node in toc_tree.findall(nodes.reference):
4243
node["refuri"] = node["anchorname"] or '#' # fix targets
4344
toc = self.render_partial(toc_tree)["fragment"]

pep_sphinx_extensions/pep_processor/html/pep_html_translator.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,17 @@ def depart_label(self, node) -> None:
8989
# Close the def tags
9090
self.body.append("</dt>\n<dd>")
9191

92+
def visit_bullet_list(self, node):
93+
if isinstance(node.parent, nodes.section) and "contents" in node.parent["names"]:
94+
self.body.append("<details><summary>Contents</summary>")
95+
self.context.append("</details>")
96+
super().visit_bullet_list(node)
97+
98+
def depart_bullet_list(self, node):
99+
super().depart_bullet_list(node)
100+
if isinstance(node.parent, nodes.section) and "contents" in node.parent["names"]:
101+
self.body.append(self.context.pop())
102+
92103
def unknown_visit(self, node: nodes.Node) -> None:
93104
"""No processing for unknown node types."""
94105
pass

pep_sphinx_extensions/pep_processor/transforms/pep_contents.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ def apply(self) -> None:
1717
if not Path(self.document["source"]).match("pep-*"):
1818
return # not a PEP file, exit early
1919
# Create the contents placeholder section
20-
title = nodes.title("", "", nodes.Text("Contents"))
21-
contents_section = nodes.section("", title)
20+
contents_section = nodes.section("")
2221
if not self.document.has_name("contents"):
2322
contents_section["names"].append("contents")
2423
self.document.note_implicit_target(contents_section)

pep_sphinx_extensions/pep_theme/static/style.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ pre {
118118
padding: .5rem .75rem;
119119
}
120120

121+
/* Contents rules */
122+
details > summary {
123+
font-weight: bold;
124+
}
125+
121126
/* Definition list rules */
122127
dl dt {
123128
font-weight: bold;

0 commit comments

Comments
 (0)