Skip to content

Commit 492dc43

Browse files
committed
Automate API doc building and update logo.
1 parent 56e2007 commit 492dc43

File tree

8 files changed

+215
-36
lines changed

8 files changed

+215
-36
lines changed

.github/workflows/build.yml

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ name: Build and Deploy
33
on: [push, pull_request]
44

55
jobs:
6-
build:
76

7+
build:
88
runs-on: ubuntu-latest
99
strategy:
1010
matrix:
@@ -19,20 +19,11 @@ jobs:
1919
- name: Install dependencies
2020
run: |
2121
python -m pip install --upgrade pip
22-
pip install pylint
23-
pip install poetry
22+
python -m pip install pylint
23+
python -m pip install poetry
2424
poetry install -v
2525
- name: Run pylint
2626
run: pylint varname.py
27-
# - name: Update docs
28-
# run: |
29-
# pip install mkdocs
30-
# pip install mkdocs-material
31-
# pip install mkapi
32-
# pip install pymdown-extensions
33-
# cd docs; ln -s ../README.md index.md; ln -s ../logo.png; cd -
34-
# mkdocs gh-deploy
35-
# if: success() && matrix.python-version == 3.8 && github.event_name == 'push'
3627
- name: Test with pytest
3728
run: poetry run pytest tests/ --junitxml=junit/test-results-${{ matrix.python-version }}.xml
3829
- name: Upload pytest test results
@@ -48,6 +39,22 @@ jobs:
4839
with:
4940
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
5041
coverage-reports: .coverage.xml
42+
43+
deploy:
44+
needs: build
45+
runs-on: ubuntu-latest
46+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
47+
strategy:
48+
matrix:
49+
python-version: [3.8]
50+
steps:
51+
- uses: actions/checkout@v2
52+
- name: Setup Python # Set Python version
53+
uses: actions/setup-python@v2
54+
- name: Install dependencies
55+
run: |
56+
python -m pip install --upgrade pip
57+
python -m pip install poetry
5158
- name: Publish to PyPI
52-
if: success() && matrix.python-version == 3.8 && github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
53-
run: poetry publish --build -u ${{ secrets.pypi_user }} -p ${{ secrets.pypi_password }}
59+
run: poetry publish --build -u ${{ secrets.PYPI_USER }} -p ${{ secrets.PYPI_PASSWORD }}
60+
if: success()

.github/workflows/docs.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Build Docs
2+
3+
on: [push]
4+
5+
jobs:
6+
docs:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
python-version: [3.8]
11+
steps:
12+
- uses: actions/checkout@v2
13+
- name: Setup Python # Set Python version
14+
uses: actions/setup-python@v2
15+
with:
16+
python-version: ${{ matrix.python-version }}
17+
- name: Install dependencies
18+
run: |
19+
python -m pip install --upgrade pip
20+
python -m pip install poetry
21+
poetry install -v
22+
- name: Update docs
23+
run: |
24+
poetry run python -m pip install mkdocs
25+
poetry run python -m pip install -r docs/requirements.txt
26+
cd docs
27+
cp ../README.md index.md
28+
cp ../logo.png ./
29+
cd ..
30+
poetry run mkdocs gh-deploy --clean --force
31+
if: success()
32+
33+
fix-index:
34+
needs: docs
35+
runs-on: ubuntu-latest
36+
strategy:
37+
matrix:
38+
python-version: [3.8]
39+
steps:
40+
- uses: actions/checkout@v2
41+
with:
42+
ref: gh-pages
43+
- name: Fix index.html
44+
run: |
45+
echo ':: head of index.html - before ::'
46+
head index.html
47+
sed -i '1,5{/^$/d}' index.html
48+
echo ':: head of index.html - after ::'
49+
head index.html
50+
if: success()
51+
- name: Commit changes
52+
run: |
53+
git config --local user.email "[email protected]"
54+
git config --local user.name "GitHub Action"
55+
git commit -m "Add changes" -a
56+
if: success()
57+
- name: Push changes
58+
uses: ad-m/github-push-action@master
59+
with:
60+
github_token: ${{ secrets.GITHUB_TOKEN }}
61+
branch: gh-pages
62+
if: success()

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,4 @@ poetry.lock
108108

109109
docs/index.md
110110
docs/logo.png
111+
docs/api/

.pylintrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,10 @@ good-names=i,
302302
z,
303303
np,
304304
nn,
305+
ns,
305306
t,
306307
t0,
308+
to,
307309
ex,
308310
rc,
309311
eq,

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
![varname][7]
22

3-
[![Pypi][3]][4] [![Github][5]][6] [![PythonVers][8]][4] [![Travis building][10]][11] [![Codacy][12]][13] [![Codacy coverage][14]][13] [![Chat on gitter][17]][18]
3+
[![Pypi][3]][4] [![Github][5]][6] [![PythonVers][8]][4] [![Building][10]][11] [![Docs and API][9]][15]
4+
[![Codacy][12]][13] [![Codacy coverage][14]][13] [![Chat on gitter][17]][18]
45

56
Dark magics about variable names in python
67

@@ -264,12 +265,13 @@ For example:
264265
[6]: https://github.com/pwwang/python-varname
265266
[7]: logo.png
266267
[8]: https://img.shields.io/pypi/pyversions/python-varname?style=flat-square
267-
[10]: https://img.shields.io/travis/pwwang/python-varname?style=flat-square
268+
[9]: https://img.shields.io/github/workflow/status/pwwang/python-varname/Build%20Docs?label=docs&style=flat-square
269+
[10]: https://img.shields.io/github/workflow/status/pwwang/python-varname/Build%20and%20Deploy?style=flat-square
268270
[11]: https://travis-ci.org/pwwang/python-varname
269271
[12]: https://img.shields.io/codacy/grade/ed851ff47b194e3e9389b2a44d6f21da?style=flat-square
270272
[13]: https://app.codacy.com/manual/pwwang/python-varname/dashboard
271273
[14]: https://img.shields.io/codacy/coverage/ed851ff47b194e3e9389b2a44d6f21da?style=flat-square
272-
[15]: https://pwwang.github.io/python-varname/api/varname/
274+
[15]: https://pwwang.github.io/python-varname/api/
273275
[16]: https://pwwang.github.io/python-varname/CHANGELOG/
274276
[17]: https://img.shields.io/gitter/room/pwwang/python-varname?style=flat-square
275277
[18]: https://gitter.im/python-varname/community

docs/api.css

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

docs/style.css

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
2+
3+
.md-typeset .admonition, .md-typeset details {
4+
font-size: .7rem !important;
5+
}
6+
7+
.md-typeset table:not([class]) td {
8+
padding: .55em 1.25em !important;
9+
}
10+
11+
.md-typeset table:not([class]) th {
12+
padding: .75em 1.25em !important;
13+
}
14+
15+
.mkapi-docstring{
16+
line-height: 1;
17+
}
18+
.mkapi-node {
19+
background-color: #f0f6fa;
20+
border-top: 3px solid #559bc9;
21+
}
22+
.mkapi-node .mkapi-object-container {
23+
background-color: #b4d4e9;
24+
padding: .12em .4em;
25+
}
26+
.mkapi-node .mkapi-object-container .mkapi-object.code {
27+
background: none;
28+
border: none;
29+
}
30+
.mkapi-node .mkapi-object-container .mkapi-object.code * {
31+
font-size: .65rem !important;
32+
}
33+
.mkapi-node pre {
34+
line-height: 1.5;
35+
}
36+
.md-typeset pre>code {
37+
overflow: visible;
38+
line-height: 1.2;
39+
}
40+
.mkapi-section-name.bases {
41+
margin-top: .2em;
42+
}
43+
.mkapi-section-body.bases {
44+
padding-bottom: .7em;
45+
line-height: 1.3;
46+
}
47+
.mkapi-section.bases {
48+
margin-bottom: .8em;
49+
}
50+
.mkapi-node * {
51+
font-size: .7rem;
52+
}
53+
.mkapi-node a.mkapi-src-link {
54+
word-break: keep-all;
55+
}
56+
.mkapi-docstring {
57+
padding: .4em .15em !important;
58+
}
59+
.mkapi-section-name-body {
60+
font-size: .72rem !important;
61+
}
62+
.mkapi-node ul.mkapi-items li {
63+
line-height: 1.4 !important;
64+
}
65+
.mkapi-node ul.mkapi-items li * {
66+
font-size: .65rem !important;
67+
}
68+
.mkapi-node code.mkapi-object-signature {
69+
padding-right: 2px;
70+
}
71+
.mkapi-node .mkapi-code * {
72+
font-size: .65rem;
73+
}
74+
.mkapi-node a.mkapi-docs-link {
75+
font-size: .6rem;
76+
}
77+
.mkapi-node h1.mkapi-object.mkapi-object-code {
78+
margin: .2em .3em;
79+
}
80+
.mkapi-node h1.mkapi-object.mkapi-object-code .mkapi-object-kind.mkapi-object-kind-code {
81+
font-style: normal;
82+
margin-right: 16px;
83+
}
84+
.mkapi-node .mkapi-item-name {
85+
font-size: .7rem !important;
86+
color: #555;
87+
padding-right: 4px;
88+
}
89+
.md-typeset {
90+
font-size: .75rem !important;
91+
line-height: 1.5 !important;
92+
}
93+
.mkapi-object-kind.package.top {
94+
font-size: .8rem !important;
95+
color: #111;
96+
97+
}
98+
.mkapi-object.package.top > h2 {
99+
font-size: .8rem !important;
100+
}
101+
102+
.mkapi-object-body.package.top * {
103+
font-size: .75rem !important;
104+
}
105+
.mkapi-object-kind.module.top {
106+
font-size: .75rem !important;
107+
color: #222;
108+
}
109+
110+
.mkapi-object-body.module.top * {
111+
font-size: .75rem !important;
112+
}

mkdocs.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
1-
site_name: python-varname
1+
site_name: varname
22
theme:
33
name: 'material'
4-
plugins:
5-
- search
6-
- mkapi
7-
extra_css:
8-
- api.css
4+
# font:
5+
# text: 'Ubuntu'
6+
# code: 'Ubuntu Mono'
97
markdown_extensions:
108
- markdown.extensions.admonition
119
- pymdownx.superfences:
1210
preserve_tabs: true
1311
- toc:
1412
baselevel: 2
13+
plugins:
14+
- search # necessary for search to work
15+
- mkapi
16+
extra_css:
17+
- style.css
1518
nav:
16-
- "": mkapi/api/varname
17-
- index.md
18-
- API: api/varname.md
19+
- '': mkapi/api/varname
20+
- 'Home': 'index.md'
21+
- 'API': 'api/varname.md'
1922
- 'Change Log': CHANGELOG.md

0 commit comments

Comments
 (0)