Skip to content

Commit b6d3b69

Browse files
docs: Add documentation for HeadingPlugin and TOCPlugin
Add comprehensive documentation for the HeadingPlugin and TOCPlugin, including configuration details, usage examples, and best practices for content organization. Documentation: - Add new documentation for the HeadingPlugin, detailing configuration options, anchor settings, and usage examples. - Introduce documentation for the TOCPlugin, explaining its dependency on heading anchors and the required rendering order. - Update the index to include the new documentation pages for HeadingPlugin and TOCPlugin. Resolves #229
1 parent 1d6a629 commit b6d3b69

File tree

3 files changed

+127
-0
lines changed

3 files changed

+127
-0
lines changed

docs/source/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ Contents
8383
custom_components
8484
grid
8585
components
86+
plugins/heading
87+
plugins/toc
8688
how-to/index
8789
reference
8890

docs/source/plugins/heading.rst

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#########
2+
Heading
3+
#########
4+
5+
The Heading plugin allows you to add headings (h1-h6) to your content with optional styling and anchors for navigation.
6+
7+
*************
8+
Configuration
9+
*************
10+
11+
- **Heading Level**: Choose h1-h6 for the heading tag
12+
- **Heading Text**: The text content of the heading
13+
- **Heading ID**: Optional anchor ID for TOC linking
14+
- **Heading Alignment**: Text alignment (left, center, right)
15+
- **Heading Context**: Optional Bootstrap contextual class for styling
16+
17+
Example
18+
=======
19+
20+
Basic heading::
21+
22+
<h2 id="my-section">My Section Title</h2>
23+
24+
To create a heading that will appear in a table of contents:
25+
26+
1. Add a Heading plugin
27+
2. Set the heading level (e.g., h2)
28+
3. Enter your heading text
29+
4. Set a unique ID in the "Heading ID" field
30+
5. Optional: Adjust alignment and styling
31+
32+
Advanced Usage
33+
=============
34+
35+
Styling
36+
-------
37+
38+
You can apply Bootstrap contextual classes through the "Heading Context" setting:
39+
40+
- primary
41+
- secondary
42+
- success
43+
- danger
44+
- warning
45+
- info
46+
- light
47+
- dark
48+
49+
For example, selecting "primary" will add the ``text-primary`` class.
50+
51+
TOC Integration
52+
--------------
53+
54+
To make a heading appear in a Table of Contents:
55+
56+
1. The heading **must** have an ID set
57+
2. The TOC plugin must be placed **after** the heading in the content flow
58+
3. Only headings with IDs will appear in the TOC
59+
60+
See the :doc:`Table of Contents </plugins/toc>` documentation for more details.

docs/source/plugins/toc.rst

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
###################
2+
Table of Contents
3+
###################
4+
5+
The Table of Contents (TOC) plugin automatically generates a navigation list from headings in your content.
6+
7+
**Important**: The TOC plugin must be placed **after** the headings it references in the content flow.
8+
9+
*************
10+
How it Works
11+
*************
12+
13+
The TOC plugin:
14+
15+
1. Scans for Heading plugins that appear before it in the content
16+
2. Collects headings that have an ID set
17+
3. Generates a nested list of links to those headings
18+
19+
Basic Usage
20+
==========
21+
22+
To create a table of contents:
23+
24+
1. Add your Heading plugins with IDs set
25+
2. Add the TOC plugin after the headings
26+
3. The TOC will automatically generate when the page renders
27+
28+
Positioning at Top of Page
29+
=========================
30+
31+
Since the TOC must be placed after headings to collect them, use grid layouts to display it at the top:
32+
33+
Two Column Layout Example
34+
------------------------
35+
36+
1. Create a container
37+
2. Add a row with two columns
38+
3. In the first (left) column:
39+
- Add the TOC plugin
40+
4. In the second (right) column:
41+
- Add your content with Heading plugins
42+
5. Set column widths appropriately (e.g., 3/9 split)
43+
44+
Example Structure::
45+
46+
Container
47+
└── Row
48+
├── Column (col-3)
49+
│ └── TOC Plugin
50+
└── Column (col-9)
51+
├── Heading Plugin
52+
├── Content...
53+
├── Heading Plugin
54+
└── More content...
55+
56+
This creates a sidebar layout with the TOC always visible while scrolling through content.
57+
58+
Best Practices
59+
=============
60+
61+
1. Always set IDs on headings that should appear in the TOC
62+
2. Use consistent heading levels for proper hierarchy
63+
3. Keep heading IDs unique across the page
64+
4. Consider using the grid layout pattern for better UX
65+
5. Test navigation on both desktop and mobile views

0 commit comments

Comments
 (0)