mirror of https://github.com/Nonannet/pelfy.git
docs added
This commit is contained in:
parent
29247df793
commit
dca6c9ae5b
|
@ -12,7 +12,7 @@ jobs:
|
|||
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: [3.9, "3.10", 3.11, 3.13]
|
||||
python-version: [3.9, "3.10", 3.11, 3.12, 3.13]
|
||||
|
||||
steps:
|
||||
- name: Check out code
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
name: Build and Deploy Docs
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v3
|
||||
with:
|
||||
python-version: "3.x"
|
||||
- name: Install dependencies
|
||||
run: pip install sphinx sphinx_rtd_theme sphinx-autodoc-typehints myst-parser
|
||||
- name: Generate Class List
|
||||
run: |
|
||||
pip install .
|
||||
python ./docs/source/generate_class_list.py
|
||||
- name: Build Docs
|
||||
run: |
|
||||
cd docs
|
||||
sphinx-apidoc -o ./source/ ../src/ -M --no-toc
|
||||
rm ./source/*.rst
|
||||
make html
|
||||
touch ./build/html/.nojekyll
|
||||
- name: Deploy to GitHub Pages
|
||||
uses: JamesIves/github-pages-deploy-action@v4
|
||||
with:
|
||||
branch: gh-pages
|
||||
folder: docs/build/html
|
|
@ -44,4 +44,8 @@ venv.bak/
|
|||
dmypy.json
|
||||
|
||||
# pytype static type analyzer
|
||||
.pytype/
|
||||
.pytype/
|
||||
|
||||
# docs
|
||||
docs/build/
|
||||
docs/source/modules.md
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
# Minimal makefile for Sphinx documentation
|
||||
#
|
||||
|
||||
# You can set these variables from the command line, and also
|
||||
# from the environment for the first two.
|
||||
SPHINXOPTS ?=
|
||||
SPHINXBUILD ?= sphinx-build
|
||||
SOURCEDIR = source
|
||||
BUILDDIR = build
|
||||
|
||||
# Put it first so that "make" without argument is like "make help".
|
||||
help:
|
||||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||
|
||||
.PHONY: help Makefile
|
||||
|
||||
# Catch-all target: route all unknown targets to Sphinx using the new
|
||||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
||||
%: Makefile
|
||||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
|
@ -0,0 +1,35 @@
|
|||
@ECHO OFF
|
||||
|
||||
pushd %~dp0
|
||||
|
||||
REM Command file for Sphinx documentation
|
||||
|
||||
if "%SPHINXBUILD%" == "" (
|
||||
set SPHINXBUILD=sphinx-build
|
||||
)
|
||||
set SOURCEDIR=source
|
||||
set BUILDDIR=build
|
||||
|
||||
%SPHINXBUILD% >NUL 2>NUL
|
||||
if errorlevel 9009 (
|
||||
echo.
|
||||
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
||||
echo.installed, then set the SPHINXBUILD environment variable to point
|
||||
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
||||
echo.may add the Sphinx directory to PATH.
|
||||
echo.
|
||||
echo.If you don't have Sphinx installed, grab it from
|
||||
echo.https://www.sphinx-doc.org/
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
if "%1" == "" goto help
|
||||
|
||||
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
||||
goto end
|
||||
|
||||
:help
|
||||
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
||||
|
||||
:end
|
||||
popd
|
|
@ -0,0 +1,32 @@
|
|||
# Configuration file for the Sphinx documentation builder.
|
||||
#
|
||||
# For the full list of built-in configuration values, see the documentation:
|
||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html
|
||||
|
||||
# -- Project information -----------------------------------------------------
|
||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
|
||||
|
||||
import os
|
||||
import sys
|
||||
sys.path.insert(0, os.path.abspath("../src/"))
|
||||
|
||||
project = 'pyhoff'
|
||||
copyright = '2025, Nicolas Kruse'
|
||||
author = 'Nicolas Kruse'
|
||||
|
||||
# -- General configuration ---------------------------------------------------
|
||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
|
||||
|
||||
extensions = ["sphinx.ext.autodoc", "sphinx.ext.napoleon", "sphinx_autodoc_typehints", "myst_parser"]
|
||||
|
||||
templates_path = ['_templates']
|
||||
exclude_patterns = []
|
||||
|
||||
# -- Options for HTML output -------------------------------------------------
|
||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
|
||||
|
||||
# html_theme = 'alabaster'
|
||||
html_theme = 'sphinx_rtd_theme'
|
||||
html_static_path = ['_static']
|
||||
|
||||
autodoc_inherit_docstrings = True
|
|
@ -0,0 +1,59 @@
|
|||
import importlib
|
||||
import inspect
|
||||
import fnmatch
|
||||
from io import TextIOWrapper
|
||||
|
||||
def write_classes(f: TextIOWrapper, patterns: list[str], module_name: str, title: str, description: str = '', exclude: list[str] = []) -> None:
|
||||
|
||||
module = importlib.import_module(module_name)
|
||||
|
||||
classes = [
|
||||
name for name, obj in inspect.getmembers(module, inspect.isclass)
|
||||
if (obj.__module__ == module_name and
|
||||
any(fnmatch.fnmatch(name, pat) for pat in patterns if pat not in exclude) and
|
||||
obj.__doc__ and '(Automatic generated stub)' not in obj.__doc__)
|
||||
]
|
||||
|
||||
"""Write the classes to the file."""
|
||||
f.write(f'## {title}\n\n')
|
||||
if description:
|
||||
f.write(f'{description}\n\n')
|
||||
|
||||
for cls in classes:
|
||||
f.write('```{eval-rst}\n')
|
||||
f.write(f'.. autoclass:: {module_name}.{cls}\n')
|
||||
f.write(' :members:\n')
|
||||
f.write(' :undoc-members:\n')
|
||||
f.write(' :show-inheritance:\n')
|
||||
f.write(' :inherited-members:\n')
|
||||
if title != 'Base classes':
|
||||
f.write(' :exclude-members: select\n')
|
||||
f.write('```\n\n')
|
||||
|
||||
|
||||
def write_functions(f: TextIOWrapper, patterns: list[str], module_name: str, title: str, description: str = '', exclude: list[str] = []) -> None:
|
||||
|
||||
module = importlib.import_module(module_name)
|
||||
|
||||
classes = [
|
||||
name for name, obj in inspect.getmembers(module, inspect.isfunction)
|
||||
if (obj.__module__ == module_name and
|
||||
any(fnmatch.fnmatch(name, pat) for pat in patterns if pat not in exclude))
|
||||
]
|
||||
|
||||
"""Write the classes to the file."""
|
||||
f.write(f'## {title}\n\n')
|
||||
if description:
|
||||
f.write(f'{description}\n\n')
|
||||
|
||||
for func in classes:
|
||||
f.write('```{eval-rst}\n')
|
||||
f.write(f'.. autofunction:: {module_name}.{func}\n')
|
||||
f.write('```\n\n')
|
||||
|
||||
|
||||
with open('docs/source/modules.md', 'w') as f:
|
||||
f.write('# Functions and classes\n\n')
|
||||
write_functions(f, ['*'], 'pelfy', title='Functions')
|
||||
write_classes(f, ['elf_*'], 'pelfy', title='ELF classes')
|
||||
write_classes(f, ['*_list'], 'pelfy', title='Lists of ELF classes')
|
|
@ -0,0 +1,10 @@
|
|||
```{toctree}
|
||||
:maxdepth: 2
|
||||
:caption: Contents:
|
||||
|
||||
readme
|
||||
modules
|
||||
```
|
||||
|
||||
```{include} ../../README.md
|
||||
```
|
|
@ -0,0 +1,2 @@
|
|||
```{include} ../../README.md
|
||||
```
|
|
@ -1,21 +1,21 @@
|
|||
[project]
|
||||
name = "pelfy"
|
||||
version = "1.0.1"
|
||||
version = "1.0.2"
|
||||
authors = [
|
||||
{ name="Nicolas Kruse", email="nicolas.kruse@nonan.net" },
|
||||
]
|
||||
description = "Parser for ELF files written in python"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.9"
|
||||
license = "MIT"
|
||||
classifiers = [
|
||||
"Programming Language :: Python :: 3",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Operating System :: OS Independent",
|
||||
]
|
||||
|
||||
[project.urls]
|
||||
Homepage = "https://github.com/Nonannet/pelfy"
|
||||
Issues = "https://github.com/Nonannet/pelfy/issues"
|
||||
documentation = "https://nonannet.github.io/pelfy/"
|
||||
|
||||
[build-system]
|
||||
requires = ["setuptools>=61.0"]
|
||||
|
@ -24,6 +24,11 @@ build-backend = "setuptools.build_meta"
|
|||
[tool.setuptools.packages.find]
|
||||
where = ["src"]
|
||||
|
||||
[project.optional-dependencies]
|
||||
dev = [
|
||||
"pytest", "flake8", "mypy"
|
||||
]
|
||||
|
||||
[tool.mypy]
|
||||
files = ["src", "tests"]
|
||||
strict = true
|
||||
|
|
Loading…
Reference in New Issue