Skip to content

Commit cb7ad86

Browse files
andrzejnovakclaude
andcommitted
docs: Update examples to reflect real-world usage patterns
Updated all code examples in README and documentation to use more realistic scenarios: - Replaced generic examples with practical use cases - Added clear organizational vs standalone project patterns - Included proper comments in YAML examples - Used realistic project names and URLs (your-org/your-project) - Emphasized shared config approach for organizations - Added step-by-step guides for common workflows - Made nested dropdown examples more comprehensive This makes it easier for new users to understand how to apply the plugin to their specific use case. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent b20a291 commit cb7ad86

File tree

3 files changed

+129
-38
lines changed

3 files changed

+129
-38
lines changed

README.md

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,47 @@ pip install -e /path/to/mkdocs_header_dropdown
1616
pip install git+https://github.com/cms-cat/mkdocs-header-dropdown.git
1717
```
1818

19-
## Configuration
19+
## Quick Start
2020

21-
Add the plugin to your `mkdocs.yml` configuration file:
21+
### Option 1: Using a Shared Config (Recommended for Organizations)
22+
23+
If you're part of an organization with shared documentation links:
24+
25+
```bash
26+
# Add the shared config as a git submodule
27+
git submodule add https://github.com/your-org/docs-common.git
28+
```
2229

2330
```yaml
31+
# mkdocs.yml
32+
plugins:
33+
- search
34+
- header-dropdown:
35+
config_file: "docs-common/header-dropdown.yml"
36+
```
37+
38+
### Option 2: Direct Configuration
39+
40+
For standalone projects:
41+
42+
```yaml
43+
# mkdocs.yml
2444
plugins:
2545
- search
2646
- header-dropdown:
2747
dropdowns:
28-
- title: "CMS POG Docs"
29-
icon: "/assets/CMSlogo_white_nolabel_1024_May2014.png"
48+
- title: "Documentation"
3049
links:
31-
- text: "Analysis Corrections | CrossPOG"
32-
url: "https://cms-analysis-corrections.docs.cern.ch/"
33-
target: "_blank"
34-
- text: "BTV Docs"
35-
url: "https://btv-wiki.docs.cern.ch/"
50+
- text: "Getting Started"
51+
url: "/getting-started/"
52+
- text: "User Guide"
53+
url: "/guide/"
54+
- text: "API Reference"
55+
url: "/api/"
56+
- title: "External Links"
57+
links:
58+
- text: "GitHub Repository"
59+
url: "https://github.com/your-org/your-project"
3660
target: "_blank"
3761
```
3862

example/docs/getting-started.md

Lines changed: 78 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,61 +15,97 @@ pip install git+https://github.com/cms-cat/mkdocs-header-dropdown-plugin.git
1515
The minimal configuration requires just the plugin and at least one dropdown:
1616

1717
```yaml
18+
# mkdocs.yml
1819
plugins:
20+
- search
1921
- header-dropdown:
2022
dropdowns:
21-
- title: "Links"
23+
- title: "Documentation"
2224
links:
2325
- text: "Home"
2426
url: "/"
27+
- text: "Getting Started"
28+
url: "/getting-started/"
2529
```
2630
2731
## Adding Icons
2832
29-
You can add icons to your dropdowns:
33+
You can add icons to your dropdowns. The icon path should be relative to your docs directory:
3034
3135
```yaml
36+
# mkdocs.yml
3237
plugins:
3338
- header-dropdown:
3439
dropdowns:
35-
- title: "Documentation"
36-
icon: "/assets/logo.png"
40+
- title: "My Project"
41+
icon: "/assets/logo.png" # Located at docs/assets/logo.png
3742
links:
38-
- text: "Getting Started"
39-
url: "/getting-started/"
43+
- text: "Home"
44+
url: "/"
45+
- text: "Documentation"
46+
url: "/docs/"
4047
```
4148
4249
## Multiple Dropdowns
4350
4451
Add as many dropdowns as you need:
4552
4653
```yaml
54+
# mkdocs.yml
4755
plugins:
4856
- header-dropdown:
4957
dropdowns:
50-
- title: "Docs"
58+
- title: "Documentation"
5159
links:
52-
- text: "Guide"
60+
- text: "User Guide"
5361
url: "/guide/"
54-
- title: "External"
62+
- text: "API Reference"
63+
url: "/api/"
64+
- text: "Examples"
65+
url: "/examples/"
66+
- title: "Resources"
5567
links:
56-
- text: "GitHub"
57-
url: "https://github.com"
68+
- text: "GitHub Repository"
69+
url: "https://github.com/your-org/your-project"
70+
target: "_blank"
71+
- text: "Issue Tracker"
72+
url: "https://github.com/your-org/your-project/issues"
5873
target: "_blank"
5974
```
6075
6176
## Using Shared Configuration
6277
6378
For multiple documentation sites sharing the same navigation:
6479
65-
1. Create a shared config repository
66-
2. Add as git submodule
67-
3. Reference in `mkdocs.yml`:
80+
**Step 1:** Create a shared config repository (`your-org/docs-common`):
6881

6982
```yaml
83+
# header-dropdown.yml
84+
dropdowns:
85+
- title: "Company Resources"
86+
icon: "company-logo.png"
87+
links:
88+
- text: "Internal Wiki"
89+
url: "https://wiki.company.com"
90+
target: "_blank"
91+
- text: "Support Portal"
92+
url: "https://support.company.com"
93+
target: "_blank"
94+
```
95+
96+
**Step 2:** Add as git submodule to your documentation repo:
97+
98+
```bash
99+
git submodule add https://github.com/your-org/docs-common.git
100+
```
101+
102+
**Step 3:** Reference in `mkdocs.yml`:
103+
104+
```yaml
105+
# mkdocs.yml
70106
plugins:
71107
- header-dropdown:
72-
config_file: "shared-config/dropdowns.yml"
108+
config_file: "docs-common/header-dropdown.yml"
73109
```
74110

75111
**Live Example**: The "CMS POG Docs" dropdown in this site's header is loaded from the [cms-docs-common](https://github.com/cms-cat/cms-docs-common) repository via git submodule!
@@ -79,44 +115,59 @@ plugins:
79115
You can combine shared config with site-specific dropdowns:
80116

81117
```yaml
118+
# mkdocs.yml
82119
plugins:
83120
- header-dropdown:
84-
config_file: "cms-docs-common/header-dropdown.yml" # Shared
85-
dropdowns: # Site-specific
86-
- title: "Local Links"
121+
config_file: "docs-common/header-dropdown.yml" # Shared organization links
122+
dropdowns: # Project-specific additions
123+
- title: "This Project"
87124
links:
88125
- text: "About"
89126
url: "/about/"
127+
- text: "Changelog"
128+
url: "/changelog/"
129+
- text: "Contributing"
130+
url: "/contributing/"
90131
```
91132

92-
Both will appear in the header - check this example site to see it in action!
133+
Both shared and project-specific dropdowns will appear in the header - check this example site to see it in action!
93134

94135
## Nested Dropdowns
95136

96137
You can create nested dropdowns (submenus) by using the `submenu` key instead of `url`:
97138

98139
```yaml
140+
# mkdocs.yml
99141
plugins:
100142
- header-dropdown:
101143
dropdowns:
102144
- title: "Resources"
103145
links:
104-
- text: "GitHub"
105-
url: "https://github.com/example"
106-
- text: "Documentation" # This will have an arrow
146+
- text: "GitHub Repository"
147+
url: "https://github.com/your-org/your-project"
148+
target: "_blank"
149+
- text: "Documentation" # This will have an arrow →
107150
submenu:
108151
- text: "User Guide"
109152
url: "/guide/"
110153
- text: "API Reference"
111154
url: "/api/"
112-
- text: "FAQ"
113-
url: "/faq/"
155+
- text: "Tutorials"
156+
url: "/tutorials/"
157+
- text: "Community" # Another nested menu
158+
submenu:
159+
- text: "Forum"
160+
url: "https://forum.example.com"
161+
target: "_blank"
162+
- text: "Chat"
163+
url: "https://chat.example.com"
164+
target: "_blank"
114165
```
115166

116-
**Live Example**: Hover over the "Resources" dropdown and then hover over "Documentation" to see a nested submenu appear to the right!
167+
**Live Example**: Hover over the "Resources" dropdown in this site's header, then hover over "Documentation" to see a nested submenu appear to the right!
117168

118169
Features:
119-
- Arrow indicator (▶) shows which items have submenus
120-
- Submenus appear on hover to the right
170+
- **Arrow indicator** (▶) shows which items have submenus
171+
- **Submenus appear on hover** to the right
121172
- Works with both mouse and keyboard navigation
122173
- Multiple levels of nesting supported

example/docs/index.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,32 @@ pip install git+https://github.com/cms-cat/mkdocs-header-dropdown-plugin.git
3737

3838
## Quick Start
3939

40-
Add to your `mkdocs.yml`:
40+
**For organizations with shared links (using git submodules):**
41+
42+
```bash
43+
git submodule add https://github.com/your-org/docs-common.git
44+
```
45+
46+
```yaml
47+
# mkdocs.yml
48+
plugins:
49+
- header-dropdown:
50+
config_file: "docs-common/header-dropdown.yml"
51+
```
52+
53+
**For standalone projects:**
4154
4255
```yaml
56+
# mkdocs.yml
4357
plugins:
4458
- header-dropdown:
4559
dropdowns:
4660
- title: "Documentation"
4761
links:
62+
- text: "Getting Started"
63+
url: "/getting-started/"
4864
- text: "User Guide"
49-
url: "/user-guide/"
65+
url: "/guide/"
5066
- text: "API Reference"
5167
url: "/api/"
5268
```

0 commit comments

Comments
 (0)