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

RST-formatted documentation, guides, and related bug fixes #162

Draft
wants to merge 63 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
04691c0
Add GitHub wiki as a submodule.
aholmes Oct 25, 2024
807dc60
Add Sphinx.
aholmes Oct 30, 2024
8b48cb2
Fix more Sphinx errors.
aholmes Oct 30, 2024
c64e4ef
Document more modules and change the theme.
aholmes Oct 31, 2024
dfd6483
Add GitHub pages deployment action for Sphinx-generated documentation.
aholmes Nov 4, 2024
44c8c61
Add missing artifact upload step to GitHub page action.
aholmes Nov 4, 2024
4bba6dc
Remove unnecessary comment.
aholmes Nov 4, 2024
5b0f7d6
Reorganize Sphinx documentation.
aholmes Nov 4, 2024
91135ad
Add an optional dependency for working with Sphinx.
aholmes Nov 5, 2024
aded9cf
Reorganize reST docs and write Scaffolder docs.
aholmes Nov 6, 2024
726df90
Update gitmodule ref for wiki.
aholmes Nov 6, 2024
192093b
Add some documentation for working with `Ligare.web` scaffolded
aholmes Nov 7, 2024
4652f38
More documentation on scaffolded application types.
aholmes Nov 8, 2024
91cf388
More documentation reorganization.
aholmes Nov 8, 2024
3dc67c9
Start docs for adding new endpoints.
aholmes Nov 8, 2024
dcef64d
More docs.
aholmes Nov 9, 2024
5ba13bb
Add starting pages for "why" explanations of Ligare libraries.
aholmes Nov 13, 2024
f879ce4
Start "from scratch" web app guide.
aholmes Nov 15, 2024
ba88884
Stylize code in documentation. Start on OpenAPI spec docs.
aholmes Nov 16, 2024
9b131c0
Add sphinx-copybutton.
aholmes Nov 18, 2024
257dc4e
Remove old comments.
aholmes Nov 18, 2024
aa843b4
Don't run Alembic migrations when env.py is imported from anything other
aholmes Nov 18, 2024
daf5f11
Add `sphinx-autobuild` to watch for RST changes in Sphinx docs.
aholmes Nov 18, 2024
11c0d77
Fix some indexes and move pages around for creating applications from
aholmes Nov 19, 2024
d79f118
Wrap up "app from scratch" example.
aholmes Nov 19, 2024
2c07fe4
Additional modifications to getting started guides.
aholmes Nov 19, 2024
92b6295
Add a run method to CreateAppResult to make everyone's lives easier.
aholmes Nov 19, 2024
c738c6e
Improve error messaging for Ligare.web application builder.
aholmes Nov 19, 2024
660d0e8
Fix typo.
aholmes Nov 19, 2024
ed5af4c
Further adjustments to Ligare.web guides.
aholmes Nov 19, 2024
f8d472e
Make FlaskApp instances honor Swagger UI configuration.
aholmes Nov 19, 2024
cc33b33
Add example web application.
aholmes Nov 20, 2024
026c2ef
Make generated Sphinx docs link between source and docs.
aholmes Nov 20, 2024
0985960
Add examples and test generating related docs.
aholmes Nov 20, 2024
2d9cf3a
Improve `example` extlink and add to "from scratch" guide.
aholmes Nov 20, 2024
c4f7eb2
Archive examples during Sphinx build.
aholmes Nov 20, 2024
c9519c6
Update "from scratch" guide to use new directives.
aholmes Nov 20, 2024
fc4aa3b
Remove octal value for decimal argument.
aholmes Nov 20, 2024
b8ac952
Ignore some new dirs.
aholmes Nov 20, 2024
31db655
Trigger `sphinx-autobuild` when Python source files change.
aholmes Nov 21, 2024
64b948f
Add docstrings to some Ligare library modules.
aholmes Nov 22, 2024
310c313
Add application builder class to Ligare.programming.
aholmes Nov 26, 2024
73b7fdb
Rework how is executed.
aholmes Nov 26, 2024
d0e7c78
Delete `create_app` deprecated functions.
aholmes Jan 2, 2025
fbf0a65
Refactor ApplicationBuilder to move it from `Ligare.web` to `Ligare.p…
aholmes Jan 3, 2025
811a262
Fix type error caused by using a structural type interface for a base
aholmes Jan 3, 2025
59634e7
Fix some type and import errors.
aholmes Jan 3, 2025
31601fb
Fix remaining type issues.
aholmes Jan 3, 2025
28546bc
Add additional documentation.
aholmes Jan 7, 2025
3837520
Make the default pytest target src/ and test/
aholmes Jan 7, 2025
231415f
Ignore unnecessary comparisson error.
aholmes Jan 9, 2025
96e728e
Move py.typed files into source root to make local development of other
aholmes Jan 10, 2025
5557d6d
Fix import errors in Ligare.programming.
aholmes Jan 10, 2025
7b34dda
Add CLI example application.
aholmes Jan 13, 2025
c890f86
Update web API example.
aholmes Jan 13, 2025
9628588
Update web ApplicationConfigBuilder and ApplicationBuilder to set the
aholmes Jan 13, 2025
c385efb
Add `mock` stubs because `mock` uses a dynamic `__all__` which causes…
aholmes Jan 13, 2025
b546c3f
Skip directories in the Zip archive created from documentation.
aholmes Jan 14, 2025
5883edc
Change where `import_name` is needed.
aholmes Jan 14, 2025
1874542
Update example applications to fit changes to application builders.
aholmes Jan 14, 2025
ce8ba95
Make example applications use `__main__`.
aholmes Jan 14, 2025
0ad07ec
Prevent crash when Swagger URL is `/`
aholmes Jan 15, 2025
7b68c8d
Revise CLI application example in Sphinx docs.
aholmes Jan 18, 2025
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: 6 additions & 0 deletions .github/workflows/Sphinx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ jobs:
REWRITE_DEPENDENCIES=true \
make Sphinx-html

- name: Upload static files as artifact
id: deployment
uses: actions/upload-pages-artifact@v3
with:
path: sphinx-docs/build/html/

deploy:
needs: build

Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "Ligare.wiki"]
path = Ligare.wiki
url = https://github.com/uclahs-cds/Ligare.wiki.git
1 change: 1 addition & 0 deletions Ligare.wiki
Submodule Ligare.wiki added at ef07c5
26 changes: 25 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ PYPI_REPO ?= testpypi
REPORTS_DIR ?= reports
BANDIT_REPORT := bandit.sarif
PYTEST_REPORT := pytest
PYTEST_TARGET ?= .
PYTEST_TARGET ?= 'src test'
TOX_DIR := .tox


Expand Down Expand Up @@ -256,3 +256,27 @@ reset-check:
reset : reset-check clean
git checkout -- $(PYPROJECT_FILES)


SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

Sphinx-help: $(VENV) $(DEFAULT_TARGET)
@$(ACTIVATE_VENV) && \
$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: Sphinx-help Makefile

Sphinx: $(VENV) $(DEFAULT_TARGET) Makefile
$(MAKE) Sphinx-html

Sphinx-%: $(VENV) $(DEFAULT_TARGET) Makefile
$(ACTIVATE_VENV) && \
$(SPHINXBUILD) -M $(patsubst Sphinx-%,%,$@) "sphinx-docs/$(SOURCEDIR)" "sphinx-docs/$(BUILDDIR)" $(SPHINXOPTS)

Sphinx-autobuild: $(VENV) $(DEFAULT_TARGET) Makefile
$(ACTIVATE_VENV) && \
sphinx-autobuild "sphinx-docs/$(SOURCEDIR)" "sphinx-docs/$(BUILDDIR)/html" \
--watch src/ --ignore "!src/**/*.py" --ignore "src/*/test/**" \
-j auto
File renamed without changes.
31 changes: 31 additions & 0 deletions examples/cli-app/app/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from injector import inject
from Ligare.programming.application import ApplicationBase, ApplicationBuilder
from Ligare.programming.config import Config
from typing_extensions import override


class Application(ApplicationBase):
@inject
@override
def run(self, config: "AppConfig"):
print(config.message)
input("\nPress anything to exit. ")


builder = ApplicationBuilder(Application)


class AppConfig(Config):
message: str


builder.use_configuration(
lambda config_builder: config_builder \
.with_config_type(AppConfig) \
.with_config_filename("app/config.toml")
)

application = builder.build()

if __name__ == "__main__":
application.run()
2 changes: 2 additions & 0 deletions examples/cli-app/app/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[app]
message = "Hello, world!"
7 changes: 7 additions & 0 deletions examples/cli-app/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[project]
requires-python = ">= 3.10"

name = "cli-app"
version = "0.0.1"

dependencies = ["Ligare.programming"]
File renamed without changes.
15 changes: 15 additions & 0 deletions examples/web-api/app/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from Ligare.web.application import ApplicationBuilder
from connexion import FlaskApp

application_builder = ApplicationBuilder(FlaskApp)

application_builder.use_configuration(
lambda config_builder: \
config_builder \
.with_config_filename("app/config.toml")
)

application = application_builder.build()

if __name__ == "__main__":
application.run()
8 changes: 8 additions & 0 deletions examples/web-api/app/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[logging]
format = 'plaintext'

[flask]
app_name = 'app'

[flask.openapi]
spec_path = 'openapi.yaml'
16 changes: 16 additions & 0 deletions examples/web-api/app/openapi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
info:
title: Test Application
version: 3.0.3
openapi: 3.0.3
paths:
/:
get:
description: Say "Hello, World!"
operationId: app.root.get
responses:
"200":
content:
application/json:
schema:
type: string
description: Said "Hello, World!" successfully
2 changes: 2 additions & 0 deletions examples/web-api/app/root.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def get():
return "Hello, World!"
9 changes: 9 additions & 0 deletions examples/web-api/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[project]
requires-python = ">= 3.10"

name = "web-api"
version = "0.0.1"

dependencies = [
"Ligare.web"
]
37 changes: 32 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,19 @@ dev-dependencies = [
"pyright == 1.1.391",
"isort ~= 5.13",
"ruff ~= 0.3",
"bandit[sarif,toml] ~= 1.7"
"bandit[sarif,toml] ~= 1.7",
"sphinx",
"sphinx-autodoc-typehints",
"sphinx_toolbox",
"sphinx-rtd-theme",
"sphinx-copybutton",
"sphinx-autobuild"
]

# Install if you want to use the Esbonio extension
# in VSCode to write reStructuredText documents.
vscode-sphinx = [
"esbonio"
]

[tool.pyright]
Expand All @@ -113,7 +125,11 @@ exclude = [
".git",
"**/typings",
"**/node_modules",
"**/__pycache__"
"**/__pycache__",
"docs",
"sphinx-docs",
"examples",
"Ligare.wiki"
]

extraPaths = [
Expand Down Expand Up @@ -191,7 +207,7 @@ addopts = [

python_files = "test_*.py"

norecursedirs = "__pycache__ build .pytest_cache *.egg-info .venv .github-venv"
norecursedirs = "__pycache__ build .pytest_cache *.egg-info .venv .github-venv docs sphinx-docs examples Ligare.wiki"

[tool.tox]
legacy_tox_ini = """
Expand Down Expand Up @@ -242,7 +258,11 @@ omit = [
"*/typings/*",
"node_modules/*",
"__pycache__/*",
"*/__pycache__/*"
"*/__pycache__/*",
"docs/*",
"sphinx-docs",
"examples",
"Ligare.wiki"
]
branch = true

Expand All @@ -256,9 +276,16 @@ exclude_dirs = [
"./__pycache__/*",
"./.github/*",
"./.venv/*",
".venv", # ignore any deeper .venv dirs too
"./.tox/*",
".git",
"./.git/*",
"./test/*/test*.py",
"./src/*/test/*/test*.py"
"./src/*/test/*/test*.py",
"./docs/*",
"./sphinx-docs/*",
"./examples/*",
"./Ligare.wiki/*"
]

[tool.ruff]
Expand Down
1 change: 1 addition & 0 deletions sphinx-docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
source/source/generated/*.rst
12 changes: 12 additions & 0 deletions sphinx-docs/source/_static/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* change `..code-block:: shell-session` prompt appearance */
.highlight .gp {
color: #616161;
font-style: italic;
}

/* put `literalinclude` captions on the left and closer to coe blocks */
.rst-content .literal-block-wrapper .code-block-caption {
text-align: left;
padding-bottom: 0.5em;
margin-top: -1.5em;
}
Loading
Loading