Skip to content

Commit cb53e1e

Browse files
authored
Improve documentation with direct use of MkDocs (#398)
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/). - Fix list levels in table of contents on home page. - Thanks to `mdx_truly_sane_lists`. - Remove broken "edit" links. Portray is great but I think we can do better by directly using MkDocs. The new way to deploy the documentation is: mkdocs gh-deploy
1 parent 769a040 commit cb53e1e

File tree

9 files changed

+54
-25
lines changed

9 files changed

+54
-25
lines changed

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
include LICENSE *.md *.yml *.toml
22

33
include tox.ini
4+
recursive-include docs *.md
45
recursive-include tests *.py
56

67
include .bumpversion.cfg

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

pyproject.toml

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

requirements.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1+
black~=22.3.0
12
bumpversion
23
click
34
flake8>=2.2.3
45
ipython
6+
mdx_truly_sane_lists~=1.2
7+
mkdocs-include-markdown-plugin~=3.3.0
8+
mkdocs-material~=8.2.9
9+
mkdocstrings[python]~=0.18.1
10+
mkdocs~=1.3.0
511
pytest-cov
612
pytest>=3.9
713
sh>=1.09
814
tox
9-
wheel
1015
twine
11-
portray
16+
wheel

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)