Skip to content

Commit fd6e50c

Browse files
committed
Improve documentation with direct use of MkDocs
Improvements: - Only the public API is documented - Thanks to `mkdocstrings` with `show_submodules: no`. - Function parameter documentation is parsed and shown in tables. - `None` paragraphs are removed. - This was reported at timothycrosley/pdocs#25 but hasn't been merged. - Footer layout is fixed. - It's currently broken with Portray, even on their own documentation (https://timothycrosley.github.io/portray/). Portray is great but I think we can do better by directly using MkDocs.
1 parent 7d9cd4b commit fd6e50c

File tree

8 files changed

+49
-25
lines changed

8 files changed

+49
-25
lines changed

docs/changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../CHANGELOG.md

docs/contributing.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../CONTRIBUTING.md

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../README.md

docs/reference.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Reference
2+
3+
::: dotenv

mkdocs.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
site_name: python-dotenv
2+
repo_url: https://github.com/theskumar/python-dotenv
3+
theme:
4+
name: material
5+
palette:
6+
primary: green
7+
plugins:
8+
- mkdocstrings:
9+
handlers:
10+
python:
11+
rendering:
12+
show_root_heading: yes
13+
show_submodules: no
14+
separate_signature: yes
15+
- search
16+
nav:
17+
- Home: index.md
18+
- Changelog: changelog.md
19+
- Contributing: contributing.md
20+
- Reference: reference.md

pyproject.toml

Lines changed: 0 additions & 5 deletions
This file was deleted.

requirements.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1+
black
12
bumpversion
23
click
34
flake8>=2.2.3
45
ipython
6+
mkdocs
7+
mkdocs-include-markdown-plugin
8+
mkdocs-material
9+
mkdocstrings[python]
510
mock
611
pytest-cov
712
pytest>=3.9
813
sh>=1.09
914
tox
15+
twine
1016
types-mock
1117
wheel
12-
twine
13-
portray

src/dotenv/main.py

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,10 @@ def unset_key(
198198
encoding: Optional[str] = "utf-8",
199199
) -> Tuple[Optional[bool], str]:
200200
"""
201-
Removes a given key from the given .env
201+
Removes a given key from the given `.env` file.
202202
203-
If the .env path given doesn't exist, fails
204-
If the given key doesn't exist in the .env, fails
203+
If the .env path given doesn't exist, fails.
204+
If the given key doesn't exist in the .env, fails.
205205
"""
206206
if not os.path.exists(dotenv_path):
207207
logger.warning("Can't delete from %s - it doesn't exist.", dotenv_path)
@@ -316,16 +316,17 @@ def load_dotenv(
316316
) -> bool:
317317
"""Parse a .env file and then load all the variables found as environment variables.
318318
319-
- *dotenv_path*: absolute or relative path to .env file.
320-
- *stream*: Text stream (such as `io.StringIO`) with .env content, used if
321-
`dotenv_path` is `None`.
322-
- *verbose*: whether to output a warning the .env file is missing. Defaults to
323-
`False`.
324-
- *override*: whether to override the system environment variables with the variables
325-
in `.env` file. Defaults to `False`.
326-
- *encoding*: encoding to be used to read the file.
319+
Parameters:
320+
dotenv_path: Absolute or relative path to .env file.
321+
stream: Text stream (such as `io.StringIO`) with .env content, used if
322+
`dotenv_path` is `None`.
323+
verbose: Whether to output a warning the .env file is missing.
324+
override: Whether to override the system environment variables with the variables
325+
from the `.env` file.
326+
encoding: Encoding to be used to read the file.
327327
328-
If both `dotenv_path` and `stream`, `find_dotenv()` is used to find the .env file.
328+
If both `dotenv_path` and `stream` are `None`, `find_dotenv()` is used to find the
329+
.env file.
329330
"""
330331
if dotenv_path is None and stream is None:
331332
dotenv_path = find_dotenv()
@@ -356,12 +357,10 @@ def dotenv_values(
356357
`{"foo": None}`
357358
358359
Parameters:
359-
360-
- `dotenv_path`: absolute or relative path to the .env file.
361-
- `stream`: `StringIO` object with .env content, used if `dotenv_path` is `None`.
362-
- `verbose`: whether to output a warning if the .env file is missing. Defaults to
363-
`False`.
364-
- `encoding`: encoding to be used to read the file. Defaults to `"utf-8"`.
360+
dotenv_path: Absolute or relative path to the .env file.
361+
stream: `StringIO` object with .env content, used if `dotenv_path` is `None`.
362+
verbose: Whether to output a warning if the .env file is missing.
363+
encoding: Encoding to be used to read the file.
365364
366365
If both `dotenv_path` and `stream` are `None`, `find_dotenv()` is used to find the
367366
.env file.

0 commit comments

Comments
 (0)