Skip to content
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

Feature v2 #60

Merged
merged 148 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
148 commits
Select commit Hold shift + click to select a range
9a43f77
Create src directory
daizutabi Dec 24, 2023
c19fd84
linker.py
daizutabi Dec 24, 2023
a224697
typing.py
daizutabi Dec 24, 2023
7e2ee74
signature.py
daizutabi Dec 24, 2023
ee9bee2
base.py
daizutabi Dec 25, 2023
a9b9503
preprocess.py
daizutabi Dec 25, 2023
1b5f86f
link.py
daizutabi Dec 25, 2023
3432de4
typing.py
daizutabi Dec 25, 2023
0810464
type_string
daizutabi Dec 26, 2023
06a06fa
attributes.py
daizutabi Dec 28, 2023
fc990cc
inspect module
daizutabi Dec 28, 2023
3f18dc3
object.py
daizutabi Dec 28, 2023
e3e1295
inherit.py
daizutabi Dec 28, 2023
94d84bf
structure.py
daizutabi Dec 28, 2023
c238d5f
test_link
daizutabi Dec 28, 2023
65937bb
test_link noqa
daizutabi Dec 28, 2023
619e6a8
module-node
daizutabi Dec 28, 2023
a3a27f8
test_node
daizutabi Dec 28, 2023
a6600b2
test_object
daizutabi Dec 28, 2023
10cccd3
type_string: fallback -> get_link
daizutabi Dec 28, 2023
78a4792
module.py
daizutabi Dec 28, 2023
87a6ba6
node.py: is_member
daizutabi Dec 28, 2023
d6ea320
docstring.py
daizutabi Dec 28, 2023
e6d3701
inherit.py
daizutabi Dec 28, 2023
0bcff39
page.py
daizutabi Dec 28, 2023
a8762c4
postprocess.py
daizutabi Dec 28, 2023
8c30769
typing.py
daizutabi Dec 28, 2023
b0947ec
plugin
daizutabi Dec 28, 2023
24d9e63
renderer.py
daizutabi Dec 29, 2023
bf9a582
before typechecking
daizutabi Dec 29, 2023
b4a11b0
Copy
daizutabi Dec 29, 2023
eafd302
ast
daizutabi Dec 30, 2023
db9cb2f
import names
daizutabi Dec 30, 2023
8f81e19
get_names
daizutabi Dec 30, 2023
766a713
first plugin
daizutabi Dec 31, 2023
eec51a1
Module.get_tree
daizutabi Dec 31, 2023
518424e
get_arguments
daizutabi Jan 1, 2024
089b8a2
ast -> ast.node
daizutabi Jan 1, 2024
105ccae
expr
daizutabi Jan 1, 2024
c375ed8
_Items
daizutabi Jan 1, 2024
7ba0e2d
TypeAlias
daizutabi Jan 1, 2024
0dd7f9d
Remove unused functions
daizutabi Jan 1, 2024
8421ea8
type_param
daizutabi Jan 1, 2024
488245b
iter_identifiers
daizutabi Jan 2, 2024
e18ef4e
themes templates
daizutabi Jan 2, 2024
44ebb26
Argument -> Parameter
daizutabi Jan 3, 2024
b5e2fa9
docstring.py
daizutabi Jan 3, 2024
3eda03d
Delete container
daizutabi Jan 3, 2024
dc24d7f
Docstring class
daizutabi Jan 3, 2024
9e3a60d
Get module from name
daizutabi Jan 3, 2024
651314a
Store source
daizutabi Jan 3, 2024
b02d80a
ast -> objects
daizutabi Jan 4, 2024
601074e
get_object
daizutabi Jan 4, 2024
7ff6302
merge docstring in module level attributes.
daizutabi Jan 4, 2024
e32b462
merge functions
daizutabi Jan 4, 2024
8628769
docstrings.merge
daizutabi Jan 5, 2024
525ab75
postprocess
daizutabi Jan 5, 2024
5426e34
CI
daizutabi Jan 5, 2024
ac1c607
get_fullname
daizutabi Jan 5, 2024
ece3699
plugin nav
daizutabi Jan 6, 2024
50e1a4a
add nav depth
daizutabi Jan 6, 2024
7d933cf
Page
daizutabi Jan 6, 2024
46d571a
before node
daizutabi Jan 6, 2024
f4f2f91
get_object
daizutabi Jan 7, 2024
7c3ba34
objects -> ast
daizutabi Jan 8, 2024
cee7b8f
get_node_docstring
daizutabi Jan 8, 2024
8df06f5
object iter
daizutabi Jan 8, 2024
0da5947
ast transformer
daizutabi Jan 8, 2024
12650f4
inspect
daizutabi Jan 8, 2024
ace591e
base classes
daizutabi Jan 9, 2024
1c64303
dataclass parameters
daizutabi Jan 9, 2024
6d044dc
Object.modulename
daizutabi Jan 9, 2024
1dd893b
Delete parent
daizutabi Jan 10, 2024
244f1f8
modules
daizutabi Jan 10, 2024
00e3812
Use contextmanager
daizutabi Jan 10, 2024
bdd5aa0
before gen
daizutabi Jan 10, 2024
2800db3
pass
daizutabi Jan 10, 2024
f6cbade
pass
daizutabi Jan 10, 2024
4197068
ImportFrom level
daizutabi Jan 10, 2024
72ef458
import
daizutabi Jan 11, 2024
d1853dd
load_module
daizutabi Jan 11, 2024
c727a67
Delete filter.py
daizutabi Jan 11, 2024
cee8796
before Docstring -> Description
daizutabi Jan 11, 2024
06e4de6
Type, Text classes
daizutabi Jan 11, 2024
112559e
get_member
daizutabi Jan 12, 2024
ad99846
Delete contextmanager
daizutabi Jan 12, 2024
f346244
link
daizutabi Jan 12, 2024
48975c8
delete old
daizutabi Jan 12, 2024
652d964
converters -> pages
daizutabi Jan 13, 2024
68bbbd0
Element class
daizutabi Jan 13, 2024
a7df7a6
New Object
daizutabi Jan 13, 2024
533cdee
items
daizutabi Jan 14, 2024
8988c5a
merge items
daizutabi Jan 14, 2024
160cfaf
set_markdown
daizutabi Jan 14, 2024
e7528a3
plugin
daizutabi Jan 14, 2024
b1942d9
Callable class
daizutabi Jan 15, 2024
71de139
TypeKind
daizutabi Jan 15, 2024
09ee222
Delete abs_api_paths
daizutabi Jan 15, 2024
0242775
nav
daizutabi Jan 17, 2024
cb84357
test_nav
daizutabi Jan 18, 2024
a6063e5
plugins
daizutabi Jan 18, 2024
4b0d5d0
Delete Class.get_attribute
daizutabi Jan 18, 2024
d9e6284
change nav
daizutabi Jan 19, 2024
952747f
plugin log
daizutabi Jan 19, 2024
8f2901b
render_markdown
daizutabi Jan 20, 2024
c46e7b2
before attr obj
daizutabi Jan 20, 2024
425f005
attribute -> assign
daizutabi Jan 20, 2024
8956f79
New Attribute class
daizutabi Jan 20, 2024
f11740e
import get fullname
daizutabi Jan 21, 2024
989a494
globals
daizutabi Jan 23, 2024
d5a18c6
get_fullname
daizutabi Jan 24, 2024
f2be21d
get_link
daizutabi Jan 24, 2024
f55a0ab
importlib
daizutabi Jan 25, 2024
cef418d
type_string
daizutabi Jan 25, 2024
474c9d5
merge docstring
daizutabi Jan 25, 2024
7810820
inspect
daizutabi Jan 26, 2024
1b9cd06
tqdm close
daizutabi Jan 27, 2024
ac29d66
page
daizutabi Jan 27, 2024
6a72c59
extensions
daizutabi Jan 27, 2024
1a9f189
markdown
daizutabi Jan 28, 2024
9f2e9ab
resolve_with_attr
daizutabi Jan 28, 2024
533bd0a
seealso
daizutabi Jan 28, 2024
78bf3f0
get_fullname_from_object
daizutabi Jan 28, 2024
fa47cbd
get_link_from_text
daizutabi Jan 28, 2024
148d986
add_link
daizutabi Jan 28, 2024
3155013
markdown
daizutabi Jan 30, 2024
a5845b9
dedent
daizutabi Jan 30, 2024
044fdb6
code-block
daizutabi Jan 31, 2024
0e088b7
source link
daizutabi Feb 1, 2024
552dbb1
sourcelink
daizutabi Feb 1, 2024
f43456b
render_source
daizutabi Feb 2, 2024
d0c1bd6
__all__
daizutabi Feb 2, 2024
ec2d89d
move examples
daizutabi Feb 2, 2024
9d3bdc2
import_from
daizutabi Feb 2, 2024
c441828
return name
daizutabi Feb 3, 2024
d741df6
config.py
daizutabi Feb 3, 2024
1a8d48e
container
daizutabi Feb 3, 2024
53e98ec
object mode
daizutabi Feb 3, 2024
251e283
add_section
daizutabi Feb 4, 2024
1ac9176
link
daizutabi Feb 4, 2024
46e08cb
markdown sub
daizutabi Feb 5, 2024
ccc1759
markdown convert
daizutabi Feb 5, 2024
de9cc97
markdown examples empty
daizutabi Feb 5, 2024
3ffc78f
markdown
daizutabi Feb 6, 2024
b2cfe16
source link
daizutabi Feb 7, 2024
3459144
docs
daizutabi Feb 7, 2024
29d7004
Update CI
daizutabi Feb 7, 2024
e6bfdc5
find_submodule_names
daizutabi Feb 7, 2024
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
6 changes: 0 additions & 6 deletions .coveragerc

This file was deleted.

40 changes: 40 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: CI

on:
push:
branches: [main]
pull_request:

concurrency:
group: test-${{ github.head_ref }}
cancel-in-progress: true

env:
PYTHONUNBUFFERED: "1"
FORCE_COLOR: "1"

jobs:
run:
name: Python ${{ matrix.python-version }} on ${{ startsWith(matrix.os, 'macos-') && 'macOS' || startsWith(matrix.os, 'windows-') && 'Windows' || 'Linux' }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.12']

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Hatch
run: pip install --upgrade hatch
- name: Run tests
run: hatch run test
- name: Upload Codecov Results
if: success()
uses: codecov/codecov-action@v3
with:
file: lcov.info
25 changes: 25 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Documentation
on:
push:
branches: [main]
tags: ['*']
permissions:
contents: write
jobs:
deploy:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure Git Credentials
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install Hatch
run: pip install --upgrade hatch
- name: Deploy documentation
run: hatch run docs:deploy
81 changes: 69 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,74 @@
*.pyc
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
*.egg-info/
downloads/
eggs/
.eggs/
.coverage.*
.coverage
lib/
lib64/
node_modules/
parts/
sdist/
var/
package*.json
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.ropeproject/
.pytest_cache/
.mypy_cache/
tests/docs/site/
.pheasant_cache/
notebooks/
.env/
.venv/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/

# Translations
*.mo

# Scrapy stuff:
.scrapy

# PyBuilder
target/

# IPython Notebook
.ipynb_checkpoints

# pyenv
.python-version

# virtualenv
venv/
ENV/

# MkDocs documentation
site*/
examples/docs/api
examples/docs/api2

lcov.info
28 changes: 0 additions & 28 deletions .travis.yml

This file was deleted.

21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

9 changes: 9 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MIT License

Copyright (c) 2020-present daizutabi <daizutabi@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
5 changes: 0 additions & 5 deletions MANIFEST.in

This file was deleted.

76 changes: 36 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
# MkAPI

[![PyPI version][pypi-image]][pypi-link]
[![Python versions][pyversions-image]][pyversions-link]
[![Travis][travis-image]][travis-link]
[![AppVeyor][appveyor-image]][appveyor-link]
[![Coverage Status][coveralls-image]][coveralls-link]
[![Code style: black][black-image]][black-link]

# MkApi
MkAPI plugin for [MkDocs](https://www.mkdocs.org/) generates
API documentation for Python code.

MkApi plugin for [MkDocs](https://www.mkdocs.org/) generates API documentation for Python code. MkApi supports two styles of docstrings: [Google](http://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings) and [NumPy](https://numpydoc.readthedocs.io/en/latest/format.html#docstring-standard).
MkAPI supports two styles of docstrings:
[Google](http://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings) and
[NumPy](https://numpydoc.readthedocs.io/en/latest/format.html#docstring-standard).

Features of MkApi are:
Features of MkAPI are:

* **Type annotation**: If you write your function such as `def func(x: int) -> str:`, you don't need write type(s) in Parameters, Returns, or Yields section again. You can overwrite the type annotation in the corresponding docstring.
* **Object type inspection**: MkApi plugin creates *class*, *dataclass*, *function*, or *generator* prefix for each object.
* **Attribute inspection**: If you write attributes with description as comment in module or class, Attributes section is automatically created.
* **Docstring inheritance**: Docstring of a subclass can inherit parameters and attributes description from its superclasses.
* **Table of Contents**: Table of contents are inserted into the documentation of each package, module, and class.
* **Page mode**: Comprehensive API documentation for your project, in which objects are linked to each other by type annotation.
* **Bidirectional Link**: Using the Page mode, bidirectional links are created between documentation and source code.
* **Type annotation**: If you write your function such as
`def func(x: int) -> str:`, you don't need write type(s)
in Parameters, Returns, or Yields section again.
You can overwrite the type annotation in the corresponding docstring.
* **Object type inspection**: MkAPI plugin creates *class*,
*dataclass*, *function*, *method*, *property* prefix for each object.
* **Docstring inheritance**: Docstring of a subclass can inherit parameters
and attributes description from its superclasses.
* **Table of Contents**: Table of contents are inserted into the documentation
of each package, module, and class.
* **Bidirectional Link**: Bidirectional links are created between
documentation and source code.

## Installation

Expand All @@ -33,64 +40,53 @@ Add the following lines to `mkdocs.yml`:

~~~yml
plugins:
- search # necessary for search to work
- mkapi
~~~

## Usage

MkApi provides two modes to generate API documentation: Embedding mode and Page mode.
MkAPI provides two modes to generate API documentation:
Object mode and Page mode.

### Embedding Mode
### Object Mode

To generate the API documentation in a Markdown source, add an exclamation mark (!), followed by `mkapi` in brackets, and the object full name in parentheses. Yes, this is like adding an image. The object can be a function, class, or module.
To generate the API documentation in a Markdown source,
add three colons + object full name.
The object can be a function, class, attribute, or module.

~~~markdown
![mkapi](<package.module.object>)
::: package.module.object
~~~

You can combine this syntax with Markdown heading:

~~~markdown
## ![mkapi](<package.module.object>)
## ::: package.module.object
~~~

MkApi imports objects that you specify. If they aren't in the `sys.path`, configure `mkdocs.yml` like below:

~~~yml
plugins:
- search
- mkapi:
src_dirs: [<path1>, <path2>, ...]
~~~

Here, `pathX`s are inserted to `sys.path`. These `pathX`s must be relative to the `mkdocs.yml` directory.

The embedding mode is useful to embed an object interface in an arbitrary position of a Markdown source. For more details, see:
The embedding mode is useful to embed an object interface
in an arbitrary position of a Markdown source. For more details, see:

* [Google style examples](https://mkapi.daizutabi.net/examples/google_style)
* [NumPy style examples](https://mkapi.daizutabi.net/examples/numpy_style)

### Page Mode

Using the page mode, you can construct a comprehensive API documentation for your project. You can get this powerful feature by just one line:
Using the page mode, you can construct a comprehensive API documentation
for your project.
You can get this powerful feature by just one line:

~~~yaml
nav:
- index.md
- API: mkapi/api/mkapi
- API: <api>/mkapi.***
~~~

For more details, see [Page Mode and Internal Links](https://mkapi.daizutabi.net/usage/page)
For more details, see
[Page mode and internal links](https://mkapi.daizutabi.net/usage/page)

[pypi-image]: https://badge.fury.io/py/mkapi.svg
[pypi-link]: https://pypi.org/project/mkapi
[travis-image]: https://travis-ci.org/daizutabi/mkapi.svg?branch=master
[travis-link]: https://travis-ci.org/daizutabi/mkapi
[appveyor-image]: https://ci.appveyor.com/api/projects/status/ys2ic8n4j7r5j4bg/branch/master?svg=true
[appveyor-link]: https://ci.appveyor.com/project/daizutabi/mkapi
[coveralls-image]: https://coveralls.io/repos/github/daizutabi/mkapi/badge.svg?branch=master
[coveralls-link]: https://coveralls.io/github/daizutabi/mkapi?branch=master
[black-image]: https://img.shields.io/badge/code%20style-black-000000.svg
[black-link]: https://github.com/ambv/black
[pyversions-image]: https://img.shields.io/pypi/pyversions/mkapi.svg
Expand Down
25 changes: 0 additions & 25 deletions appveyor.yml

This file was deleted.

Loading
Loading