Skip to content

Commit 628b3f5

Browse files
committed
remove mkdocs build warnings
1 parent 6767b32 commit 628b3f5

File tree

4 files changed

+171
-6
lines changed

4 files changed

+171
-6
lines changed
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
# Documentation Building Guidelines
2+
3+
## Building Documentation with Strict Mode
4+
5+
The project uses MkDocs with Material theme for documentation. All documentation builds **MUST** use strict mode to catch warnings as errors and ensure documentation quality.
6+
7+
### Correct Build Command
8+
9+
The documentation build command is defined in `pyproject.toml` and includes:
10+
- `--strict` flag to treat warnings as errors
11+
- Suppression of known deprecation warnings from mkdocs-autorefs
12+
13+
**Always use:**
14+
```bash
15+
hatch run docs-build
16+
```
17+
18+
This executes:
19+
```bash
20+
python -W ignore::DeprecationWarning:mkdocs_autorefs -m mkdocs build --clean --strict
21+
```
22+
23+
### Why Strict Mode?
24+
25+
Strict mode ensures:
26+
- All documentation links are valid
27+
- All API references resolve correctly
28+
- Type annotations are complete
29+
- No broken cross-references
30+
- Documentation quality is maintained
31+
32+
### Common Issues and Solutions
33+
34+
#### Issue: Missing Type Annotations for **kwargs
35+
36+
**Error:**
37+
```
38+
WARNING - griffe: janus_client\plugin_name.py:123: No type or annotation for parameter '**kwargs'
39+
```
40+
41+
**Solution:**
42+
Add `Any` type annotation to `**kwargs`:
43+
```python
44+
from typing import Any
45+
46+
def __init__(self, **kwargs: Any) -> None:
47+
"""Initialize the plugin."""
48+
super().__init__(**kwargs)
49+
```
50+
51+
#### Issue: Broken API References
52+
53+
**Error:**
54+
```
55+
ERROR - mkdocstrings: janus_client.SomeClass could not be found
56+
```
57+
58+
**Solution:**
59+
- Verify the class/function exists in the codebase
60+
- Check the import path is correct
61+
- Ensure the class is exported in `__init__.py` if needed
62+
- Remove references to non-existent classes from `docs/reference.md`
63+
64+
#### Issue: Deprecation Warnings
65+
66+
**Error:**
67+
```
68+
DeprecationWarning: ... from mkdocs_autorefs
69+
```
70+
71+
**Solution:**
72+
These are suppressed in the build command. If new deprecation warnings appear:
73+
1. Check if they're from mkdocs-autorefs (can be suppressed)
74+
2. If from our code, fix the deprecated usage
75+
3. Update the build command in `pyproject.toml` if needed
76+
77+
### Local Development
78+
79+
For local development without strict mode (faster iteration):
80+
```bash
81+
hatch run mkdocs serve
82+
```
83+
84+
Or build without strict mode:
85+
```bash
86+
hatch run mkdocs build
87+
```
88+
89+
**Note:** Always verify with strict mode before committing!
90+
91+
### Serving Documentation Locally
92+
93+
To preview documentation with live reload:
94+
```bash
95+
hatch run docs-serve
96+
```
97+
98+
This will start a local server at http://127.0.0.1:8000/
99+
100+
### Documentation Structure
101+
102+
```
103+
docs/
104+
├── index.md # Home page with getting started
105+
├── plugins.md # Plugin usage examples
106+
├── reference.md # Auto-generated API reference
107+
├── session.md # Session management guide
108+
├── transport.md # Transport layer guide
109+
└── assets/ # Images and static files
110+
```
111+
112+
### Best Practices
113+
114+
1. **Always build with strict mode before committing**
115+
```bash
116+
hatch run docs-build
117+
```
118+
119+
2. **Test documentation locally**
120+
```bash
121+
hatch run docs-serve
122+
```
123+
124+
3. **Keep type annotations complete**
125+
- All public functions must have type hints
126+
- Use `Any` for `**kwargs` parameters
127+
- Use `Optional` for optional parameters
128+
129+
4. **Verify API references**
130+
- Check that all classes/functions referenced in `docs/reference.md` exist
131+
- Remove references to deleted or renamed classes
132+
- Update references when refactoring
133+
134+
5. **Follow documentation philosophy**
135+
- Keep it simple and concise
136+
- Focus on common use cases
137+
- Don't clutter with advanced configuration details
138+
- See `.clinerules/documentation-philosophy.md`
139+
140+
### CI/CD Integration
141+
142+
The documentation build should be part of CI/CD pipeline:
143+
```yaml
144+
- name: Build documentation
145+
run: hatch run docs-build
146+
```
147+
148+
This ensures documentation quality is maintained across all contributions.
149+
150+
### Troubleshooting
151+
152+
If documentation build fails:
153+
154+
1. **Read the error message carefully** - it usually points to the exact issue
155+
2. **Check the file and line number** mentioned in the error
156+
3. **Verify type annotations** are complete
157+
4. **Check API references** in `docs/reference.md`
158+
5. **Test locally** with `hatch run docs-serve` to see the issue in context
159+
160+
### Summary
161+
162+
- ✅ Always use `hatch run docs-build` for production builds
163+
- ✅ Strict mode is mandatory for quality assurance
164+
- ✅ Complete type annotations for all `**kwargs`
165+
- ✅ Verify all API references resolve correctly
166+
- ✅ Test locally before committing
167+
- ✅ Follow the documentation philosophy

janus_client/plugin_textroom.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def on_message(data):
8484

8585
name = "janus.plugin.textroom"
8686

87-
def __init__(self, **kwargs) -> None:
87+
def __init__(self, **kwargs: Any) -> None:
8888
"""Initialize the TextRoom plugin.
8989
9090
Args:

janus_client/plugin_video_call.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def on_incoming_call(data):
8080

8181
name = "janus.plugin.videocall"
8282

83-
def __init__(self, **kwargs) -> None:
83+
def __init__(self, **kwargs: Any) -> None:
8484
"""Initialize the VideoCall plugin.
8585
8686
Args:

janus_client/plugin_video_room.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def on_publishers(data):
112112

113113
name = "janus.plugin.videoroom"
114114

115-
def __init__(self, **kwargs) -> None:
115+
def __init__(self, **kwargs: Any) -> None:
116116
"""Initialize the VideoRoom plugin.
117117
118118
Args:
@@ -373,7 +373,7 @@ async def create_room(
373373
permanent: bool = False,
374374
admin_key: Optional[str] = None,
375375
timeout: float = 15.0,
376-
**kwargs,
376+
**kwargs: Any,
377377
) -> int:
378378
"""Create a new VideoRoom.
379379
@@ -527,8 +527,6 @@ async def exists(self, room_id: int, timeout: float = 15.0) -> bool:
527527
response = await self._send_request(body, timeout=timeout)
528528
return response["plugindata"]["data"].get("exists", False)
529529

530-
# Publisher Methods
531-
532530
async def join_as_publisher(
533531
self,
534532
room_id: int,

0 commit comments

Comments
 (0)