Skip to content

Commit 78c7c49

Browse files
committed
Refactor some more docs
1 parent afb97c8 commit 78c7c49

File tree

10 files changed

+156
-156
lines changed

10 files changed

+156
-156
lines changed

docs/mkdocs.yml

Lines changed: 115 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,147 +1,137 @@
11
---
22
nav:
3-
- Get Started:
4-
- Add ReactPy-Router to Your Project: index.md
5-
- Your First Routed Application: learn/your-first-app.md
6-
- Advanced Topics:
7-
- Routers, Routes, and Links: learn/routers-routes-and-links.md
8-
- Hooks: learn/hooks.md
9-
- Creating a Custom Router 🚧: learn/custom-router.md
10-
- Reference:
11-
- Core: reference/core.md
12-
- Router: reference/router.md
13-
- Types: reference/types.md
14-
- About:
15-
- Changelog: about/changelog.md
16-
- Contributor Guide:
17-
- Code: about/code.md
18-
- Docs: about/docs.md
19-
- Community:
20-
- GitHub Discussions: https://github.com/reactive-python/reactpy-router/discussions
21-
- Discord: https://discord.gg/uNb5P4hA9X
22-
- Reddit: https://www.reddit.com/r/ReactPy/
23-
- License: about/license.md
3+
- Get Started:
4+
- Add ReactPy-Router to Your Project: index.md
5+
- Your First Routed Application: learn/your-first-app.md
6+
- Advanced Topics:
7+
- Routers, Routes, and Links: learn/routers-routes-and-links.md
8+
- Hooks: learn/hooks.md
9+
- Creating a Custom Router 🚧: learn/custom-router.md
10+
- Reference:
11+
- Router Components: reference/router.md
12+
- Components: reference/components.md
13+
- Hooks: reference/hooks.md
14+
- Types: reference/types.md
15+
- About:
16+
- Changelog: about/changelog.md
17+
- Contributor Guide:
18+
- Code: about/code.md
19+
- Docs: about/docs.md
20+
- Community:
21+
- GitHub Discussions: https://github.com/reactive-python/reactpy-router/discussions
22+
- Discord: https://discord.gg/uNb5P4hA9X
23+
- Reddit: https://www.reddit.com/r/ReactPy/
24+
- License: about/license.md
2425

2526
theme:
26-
name: material
27-
custom_dir: overrides
28-
palette:
29-
- media: "(prefers-color-scheme: dark)"
30-
scheme: slate
31-
toggle:
32-
icon: material/white-balance-sunny
33-
name: Switch to light mode
34-
primary: red # We use red to indicate that something is unthemed
35-
accent: red
36-
- media: "(prefers-color-scheme: light)"
37-
scheme: default
38-
toggle:
39-
icon: material/weather-night
40-
name: Switch to dark mode
41-
primary: white
42-
accent: red
43-
features:
44-
- navigation.instant
45-
- navigation.tabs
46-
- navigation.tabs.sticky
47-
- navigation.top
48-
- content.code.copy
49-
- search.highlight
50-
icon:
51-
repo: fontawesome/brands/github
52-
admonition:
53-
note: fontawesome/solid/note-sticky
54-
logo: https://raw.githubusercontent.com/reactive-python/reactpy/main/branding/svg/reactpy-logo-square.svg
55-
favicon: https://raw.githubusercontent.com/reactive-python/reactpy/main/branding/svg/reactpy-logo-square.svg
27+
name: material
28+
custom_dir: overrides
29+
palette:
30+
- media: "(prefers-color-scheme: dark)"
31+
scheme: slate
32+
toggle:
33+
icon: material/white-balance-sunny
34+
name: Switch to light mode
35+
primary: red # We use red to indicate that something is unthemed
36+
accent: red
37+
- media: "(prefers-color-scheme: light)"
38+
scheme: default
39+
toggle:
40+
icon: material/weather-night
41+
name: Switch to dark mode
42+
primary: white
43+
accent: red
44+
features:
45+
- navigation.instant
46+
- navigation.tabs
47+
- navigation.tabs.sticky
48+
- navigation.top
49+
- content.code.copy
50+
- search.highlight
51+
icon:
52+
repo: fontawesome/brands/github
53+
admonition:
54+
note: fontawesome/solid/note-sticky
55+
logo: https://raw.githubusercontent.com/reactive-python/reactpy/main/branding/svg/reactpy-logo-square.svg
56+
favicon: https://raw.githubusercontent.com/reactive-python/reactpy/main/branding/svg/reactpy-logo-square.svg
5657

5758
markdown_extensions:
58-
- toc:
59-
permalink: true
60-
- pymdownx.emoji:
61-
emoji_index: !!python/name:material.extensions.emoji.twemoji
62-
emoji_generator: !!python/name:material.extensions.emoji.to_svg
63-
- pymdownx.tabbed:
64-
alternate_style: true
65-
- pymdownx.highlight:
66-
linenums: true
67-
- pymdownx.superfences
68-
- pymdownx.details
69-
- pymdownx.inlinehilite
70-
- admonition
71-
- attr_list
72-
- md_in_html
73-
- pymdownx.keys
59+
- toc:
60+
permalink: true
61+
- pymdownx.emoji:
62+
emoji_index: !!python/name:material.extensions.emoji.twemoji
63+
emoji_generator: !!python/name:material.extensions.emoji.to_svg
64+
- pymdownx.tabbed:
65+
alternate_style: true
66+
- pymdownx.highlight:
67+
linenums: true
68+
- pymdownx.superfences
69+
- pymdownx.details
70+
- pymdownx.inlinehilite
71+
- admonition
72+
- attr_list
73+
- md_in_html
74+
- pymdownx.keys
7475

7576
plugins:
76-
- search
77-
- include-markdown
78-
- git-authors
79-
- minify:
80-
minify_html: true
81-
minify_js: true
82-
minify_css: true
83-
cache_safe: true
84-
- git-revision-date-localized:
85-
fallback_to_build_date: true
86-
- spellcheck:
87-
known_words: dictionary.txt
88-
allow_unicode: no
89-
ignore_code: yes
90-
skip_files:
91-
- "index.md"
92-
- "reference\\core.md"
93-
- "reference/core.md"
94-
- "reference\\types.md"
95-
- "reference/types.md"
96-
- mkdocstrings:
97-
default_handler: python
98-
handlers:
99-
python:
100-
paths: ["../"]
101-
import:
102-
- https://reactpy.dev/docs/objects.inv
103-
- https://installer.readthedocs.io/en/stable/objects.inv
104-
77+
- search
78+
- include-markdown
79+
- git-authors
80+
- minify:
81+
minify_html: true
82+
minify_js: true
83+
minify_css: true
84+
cache_safe: true
85+
- git-revision-date-localized:
86+
fallback_to_build_date: true
87+
- spellcheck:
88+
known_words: dictionary.txt
89+
allow_unicode: no
90+
- mkdocstrings:
91+
default_handler: python
92+
handlers:
93+
python:
94+
paths: ["../"]
95+
import:
96+
- https://reactpy.dev/docs/objects.inv
97+
- https://installer.readthedocs.io/en/stable/objects.inv
98+
options:
99+
show_root_heading: true
100+
show_bases: false
105101
extra:
106-
generator: false
107-
version:
108-
provider: mike
109-
analytics:
110-
provider: google
111-
property: G-XRLQYZBG00
102+
generator: false
103+
version:
104+
provider: mike
105+
analytics:
106+
provider: google
107+
property: G-XRLQYZBG00
112108

113109
extra_javascript:
114-
- assets/js/main.js
110+
- assets/js/main.js
115111

116112
extra_css:
117-
- assets/css/main.css
118-
- assets/css/button.css
119-
- assets/css/admonition.css
120-
- assets/css/banner.css
121-
- assets/css/sidebar.css
122-
- assets/css/navbar.css
123-
- assets/css/table-of-contents.css
124-
- assets/css/code.css
125-
- assets/css/footer.css
126-
- assets/css/home.css
113+
- assets/css/main.css
114+
- assets/css/button.css
115+
- assets/css/admonition.css
116+
- assets/css/banner.css
117+
- assets/css/sidebar.css
118+
- assets/css/navbar.css
119+
- assets/css/table-of-contents.css
120+
- assets/css/code.css
121+
- assets/css/footer.css
122+
- assets/css/home.css
127123

128124
watch:
129-
- "../docs"
130-
- ../README.md
131-
- ../CHANGELOG.md
132-
- ../LICENSE.md
133-
- "../src"
125+
- "../docs"
126+
- ../README.md
127+
- ../CHANGELOG.md
128+
- ../LICENSE.md
129+
- "../src"
134130

135131
site_name: ReactPy Router
136132
site_author: Archmonger
137133
site_description: It's React-Router, but in Python.
138-
copyright: '©
139-
<div id="year"></div>
140-
<script> document.getElementById("year").innerHTML = new Date().getFullYear(); </script>
141-
Reactive Python and affiliates.
142-
<div class="legal-footer-right">
143-
This project has no affiliation to ReactJS or Meta Platforms, Inc.
144-
</div>'
134+
copyright: '&copy;<div id="year"></div><script> document.getElementById("year").innerHTML = new Date().getFullYear(); </script>Reactive Python and affiliates.<div class="legal-footer-right">This project has no affiliation to ReactJS or Meta Platforms, Inc.</div>'
145135
repo_url: https://github.com/reactive-python/reactpy-router
146136
site_url: https://reactive-python.github.io/reactpy-router
147137
repo_name: ReactPy Router (GitHub)

docs/src/learn/hooks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Several pre-fabricated hooks are provided to help integrate with routing feature
66

77
---
88

9-
## Use Search Params
9+
## Use Search Parameters
1010

1111
The [`use_search_params`][src.reactpy_router.use_search_params] hook can be used to access query parameters from the current location. It returns a dictionary of query parameters, where each value is a list of strings.
1212

docs/src/reference/components.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
::: src.reactpy_router
2+
3+
options:
4+
members: ["route", "link"]

docs/src/reference/core.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/src/reference/hooks.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
::: src.reactpy_router
2+
3+
options:
4+
members: ["use_params", "use_search_params"]

docs/src/reference/router.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
::: src.reactpy_router.browser_router
1+
::: src.reactpy_router
2+
3+
options:
4+
members: ["browser_router"]

src/reactpy_router/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
create_router,
88
link,
99
route,
10-
router,
1110
use_params,
1211
use_search_params,
1312
)
@@ -21,7 +20,6 @@
2120
"route",
2221
"Route",
2322
"RouteCompiler",
24-
"router",
2523
"RouteResolver",
2624
"browser_router",
2725
"use_params",

src/reactpy_router/core.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232

3333
def route(path: str, element: Any | None, *routes: Route) -> Route:
34-
"""Create a route with the given path, element, and child routes"""
34+
"""Create a route with the given path, element, and child routes."""
3535
return Route(path, element, routes)
3636

3737

@@ -49,7 +49,10 @@ def router(
4949
*routes: R,
5050
compiler: RouteCompiler[R],
5151
) -> VdomDict | None:
52-
"""A component that renders matching route(s) using the given compiler function."""
52+
"""A component that renders matching route(s) using the given compiler function.
53+
54+
This typically should never be used by a user. Instead, use `create_router` if creating
55+
a custom routing engine."""
5356

5457
old_conn = use_connection()
5558
location, set_location = use_state(old_conn.location)
@@ -82,11 +85,10 @@ def router(
8285

8386
@component
8487
def link(*children: VdomChild, to: str, **attributes: Any) -> VdomDict:
85-
"""A component that renders a link to the given path.
86-
87-
FIXME: This currently works in a "dumb" way by trusting that ReactPy's script tag
88-
properly sets the location. When a client-server communication layer is added to a
89-
future ReactPy release, this component will need to be rewritten to use that instead."""
88+
"""A component that renders a link to the given path."""
89+
# FIXME: This currently works in a "dumb" way by trusting that ReactPy's script tag \
90+
# properly sets the location. When a client-server communication layer is added to a \
91+
# future ReactPy release, this component will need to be rewritten to use that instead. \
9092
set_location = _use_route_state().set_location
9193
uuid = uuid4().hex
9294

@@ -106,8 +108,8 @@ def on_click(_event: dict[str, Any]) -> None:
106108

107109

108110
def use_params() -> dict[str, Any]:
109-
"""The `use_params` hook returns an object of key/value pairs of the dynamic params \
110-
from the current URL that were matched by the `Route`. Child routes inherit all params \
111+
"""The `use_params` hook returns an object of key/value pairs of the dynamic parameters \
112+
from the current URL that were matched by the `Route`. Child routes inherit all parameters \
111113
from their parent routes.
112114
113115
For example, if you have a `URL_PARAM` defined in the route `/example/<URL_PARAM>/`,
@@ -126,8 +128,8 @@ def use_search_params(
126128
) -> dict[str, list[str]]:
127129
"""
128130
The `use_search_params` hook is used to read and modify the query string in the URL \
129-
for the current location. Like React's own `use_state` hook, `use_search_params returns \
130-
an array of two values: the current location's search params and a function that may \
131+
for the current location. Like React's own `use_state` hook, `use_search_params` returns \
132+
an array of two values: the current location's search parameters and a function that may \
131133
be used to update them.
132134
133135
See `urllib.parse.parse_qs` for info on this hook's parameters."""

src/reactpy_router/routers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""A simple router implementation for ReactPy"""
1+
"""URL router implementation for ReactPy"""
22

33
from __future__ import annotations
44

0 commit comments

Comments
 (0)