Skip to content

build docs on CI #127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 38 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,26 @@ jobs:
with:
extra_args: --all-files --verbose

docs-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: '3.10'

- run: pip install -r requirements/docs.txt -r requirements/pyproject.txt
- run: pip install .

- run: make docs

- name: Store docs site
uses: actions/upload-artifact@v3
with:
name: docs
path: site

test:
name: test py${{ matrix.python-version }} on ${{ matrix.os }}
strategy:
Expand Down Expand Up @@ -85,7 +105,7 @@ jobs:
# https://github.com/marketplace/actions/alls-green#why used for branch protection checks
check:
if: always()
needs: [test, lint]
needs: [test, lint, docs-build]
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
Expand All @@ -107,6 +127,17 @@ jobs:
with:
python-version: '3.10'

- name: get docs
uses: actions/download-artifact@v3
with:
name: docs
path: site

- name: check GITHUB_REF matches package version
uses: samuelcolvin/check-python-version@v3
with:
version_file_path: devtools/version.py

- name: install
run: pip install build twine

Expand All @@ -122,6 +153,10 @@ jobs:
TWINE_PASSWORD: ${{ secrets.pypi_token }}

- name: publish docs
run: make publish-docs
if: '!fromJSON(steps.check-tag.outputs.IS_PRERELEASE)'
uses: cloudflare/[email protected]
with:
apiToken: ${{ secrets.cloudflare_api_token }}
command: pages publish --project-name=python-devtools --branch=main site
env:
NETLIFY: ${{ secrets.netlify_token }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.cloudflare_account_id }}
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ clean:

.PHONY: docs
docs:
flake8 --max-line-length=80 docs/examples/
ruff --line-length=80 docs/examples/
mkdocs build

.PHONY: docs-serve
Expand Down
11 changes: 6 additions & 5 deletions devtools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# flake8: noqa
from .ansi import *
from .debug import *
from .prettier import *
from .timer import *
from .ansi import sformat, sprint
from .debug import Debug, debug
from .prettier import PrettyFormat, pformat, pprint
from .timer import Timer
from .version import VERSION

__version__ = VERSION

__all__ = 'sformat', 'sprint', 'Debug', 'debug', 'PrettyFormat', 'pformat', 'pprint', 'Timer', 'VERSION'
2 changes: 1 addition & 1 deletion docs/examples/ansi_colours.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from devtools import sprint, sformat
from devtools import sformat, sprint

sprint('this is red', sprint.red)

Expand Down
3 changes: 2 additions & 1 deletion docs/examples/complex.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from devtools import debug
import numpy as np

from devtools import debug

foo = {
'foo': np.array(range(20)),
'bar': [{'a': i, 'b': {j for j in range(1 + i * 2)}} for i in range(3)],
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/other.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# if used repeatedly a summary is available
t3 = debug.timer()
for i in [1e4, 1e6, 1e7]:
with t3('sum {}'.format(i), verbose=False):
with t3(f'sum {i}', verbose=False):
sum(range(int(i)))

t3.summary(verbose=True)
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/prettier.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from devtools import PrettyFormat, pprint, pformat
import numpy as np

from devtools import PrettyFormat, pformat, pprint

v = {
'foo': {'whatever': [3, 2, 1]},
'sentence': 'hello\nworld',
Expand Down
14 changes: 8 additions & 6 deletions requirements/docs.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
ansi2html==1.8.0
mkdocs==1.3.1
mkdocs-exclude==1.0.2
mkdocs-material==8.3.9
mkdocs-simple-hooks==0.1.5
markdown-include==0.7.0
ansi2html
mkdocs
mkdocs-exclude
mkdocs-material
mkdocs-simple-hooks
markdown-include
pygments
ruff
numpy
28 changes: 21 additions & 7 deletions requirements/docs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@
#
ansi2html==1.8.0
# via -r requirements/docs.in
certifi==2022.12.7
# via requests
charset-normalizer==3.1.0
# via requests
click==8.1.3
# via mkdocs
colorama==0.4.6
# via mkdocs-material
ghp-import==2.1.0
# via mkdocs
importlib-metadata==6.1.0
# via mkdocs
idna==3.4
# via requests
jinja2==3.1.2
# via
# mkdocs
Expand All @@ -22,26 +28,28 @@ markdown==3.3.7
# mkdocs
# mkdocs-material
# pymdown-extensions
markdown-include==0.7.0
markdown-include==0.8.1
# via -r requirements/docs.in
markupsafe==2.1.2
# via jinja2
mergedeep==1.3.4
# via mkdocs
mkdocs==1.3.1
mkdocs==1.4.2
# via
# -r requirements/docs.in
# mkdocs-exclude
# mkdocs-material
# mkdocs-simple-hooks
mkdocs-exclude==1.0.2
# via -r requirements/docs.in
mkdocs-material==8.3.9
mkdocs-material==9.1.5
# via -r requirements/docs.in
mkdocs-material-extensions==1.1.1
# via mkdocs-material
mkdocs-simple-hooks==0.1.5
# via -r requirements/docs.in
numpy==1.24.2
# via -r requirements/docs.in
packaging==23.0
# via mkdocs
pygments==2.14.0
Expand All @@ -59,9 +67,15 @@ pyyaml==6.0
# pyyaml-env-tag
pyyaml-env-tag==0.1
# via mkdocs
regex==2023.3.23
# via mkdocs-material
requests==2.28.2
# via mkdocs-material
ruff==0.0.261
# via -r requirements/docs.in
six==1.16.0
# via python-dateutil
urllib3==1.26.15
# via requests
watchdog==3.0.0
# via mkdocs
zipp==3.15.0
# via importlib-metadata