Skip to content

Commit

Permalink
fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvanmele committed Feb 29, 2024
1 parent 593cdcc commit d90b40b
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 17 deletions.
7 changes: 1 addition & 6 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,7 @@
# autodoc options

autodoc_type_aliases = {
# "Vertices": "compas_cgal.types.Vertices",
# "Faces": "compas_cgal.types.Faces",
# "VerticesFaces": "compas_cgal.types.VerticesFaces",
# "VerticesFacesNumpy": "compas_cgal.types.VerticesFacesNumpy",
# "PolylinesNumpy": "compas_cgal.types.PolylinesNumpy",
# "Planes": "compas_cgal.types.Planes",
"FloatNx3": "compas_dr.types.FloatNx3",
}

autodoc_typehints_description_target = "documented"
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ doctest_optionflags = [
# ============================================================================

[tool.bumpversion]
current_version = "0.4.2"
current_version = "0.1.0"
message = "Bump version to {new_version}"
commit = true
tag = true
Expand Down
2 changes: 1 addition & 1 deletion src/compas_dr/constraints/constraint.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Constraint(Data):
Examples
--------
>>> from compas.geometry import Line
>>> from compas_fd.constraints import Constraint
>>> from compas_dr.constraints import Constraint
>>> line = Line([0, 0, 0], [1, 0, 0])
>>> constraint = Constraint(line)
>>> constraint
Expand Down
7 changes: 4 additions & 3 deletions src/compas_dr/loads/selfweight.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
from compas.geometry import cross_vectors
from compas.geometry import length_vector
from compas.matrices import face_matrix
from compas_fd.types import FloatNx1
from compas_fd.types import FloatNx3

from compas_dr.types import FloatNx1
from compas_dr.types import FloatNx3


class SelfweightCalculator:
Expand All @@ -27,7 +28,7 @@ class SelfweightCalculator:
Examples
--------
>>> from compas.datastructures import Mesh
>>> from compas_fd.loads import SelfWeightCalculator
>>> from compas_dr.loads import SelfWeightCalculator
>>> mesh = Mesh.from_meshgrid(dx=10, nx=10)
>>> mesh.update_default_vertex_attributes(t=0.10)
>>> density = 22
Expand Down
2 changes: 1 addition & 1 deletion src/compas_dr/solvers/dr_constrained_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def dr_constrained_numpy(
----------
indata : :class:`compas_dr.numdata.InputData`
An input data object.
constraints : list[:class:`~compas_fd.constraints.Constraint`]
constraints : list[:class:`~compas_dr.constraints.Constraint`]
Vertex constraints.
kmax : int, optional
The maximum number of iterations.
Expand Down
19 changes: 19 additions & 0 deletions src/compas_dr/types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from typing import Annotated
from typing import Literal
from typing import Sequence
from typing import Union

import numpy as np
import numpy.typing as npt

FloatNx3 = Union[
Sequence[Annotated[Sequence[float], 3]],
Annotated[npt.NDArray[np.float64], Literal["*, 3"]],
]
"""An array-like object, with each item in the array containing three (3) floats."""

FloatNx1 = Union[
Sequence[Annotated[Sequence[float], 1]],
Annotated[npt.NDArray[np.float64], Literal["*, 1"]],
]
"""An array-like object, with each item in the array containing one (1) float."""
85 changes: 80 additions & 5 deletions tasks.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,56 @@
import glob
import os
import shutil
import invoke
from invoke import Collection

from compas_invocations import build
from compas_invocations import docs
from compas_invocations import docs as docs_
from compas_invocations import tests
from compas_invocations.console import chdir


@invoke.task(
help={
"docs": "True to clean up generated documentation, otherwise False",
"bytecode": "True to clean up compiled python files, otherwise False.",
"builds": "True to clean up build/packaging artifacts, otherwise False.",
}
)
def clean(ctx, docs=True, bytecode=True, builds=True, ghuser=True):
"""Cleans the local copy from compiled artifacts."""

with chdir(ctx.base_folder):
if bytecode:
for root, dirs, files in os.walk(ctx.base_folder):
for f in files:
if f.endswith(".pyc"):
os.remove(os.path.join(root, f))
if ".git" in dirs:
dirs.remove(".git")

folders = []

if docs:
folders.append("docs/api/generated")

folders.append("dist/")

if bytecode:
for t in ("src", "tests"):
folders.extend(glob.glob("{}/**/__pycache__".format(t), recursive=True))

if builds:
folders.append("build/")
folders.extend(glob.glob("src/**/*.egg-info", recursive=False))

if ghuser and ctx.get("ghuser"):
folders.append(os.path.abspath(ctx.ghuser.target_dir))

for folder in folders:
shutil.rmtree(os.path.join(ctx.base_folder, folder), ignore_errors=True)


@invoke.task()
def lint(ctx):
"""Check the consistency of coding style."""
Expand Down Expand Up @@ -42,18 +85,50 @@ def check(ctx):
lint(ctx)


@invoke.task(
help={
"rebuild": "True to clean all previously built docs before starting, otherwise False.",
"doctest": "True to run doctests, otherwise False.",
"check_links": "True to check all web links in docs for validity, otherwise False.",
}
)
def docs(ctx, doctest=False, rebuild=False, check_links=False):
"""Builds the HTML documentation."""

if rebuild:
clean(ctx)

with chdir(ctx.base_folder):
if doctest:
ctx.run("pytest --doctest-modules")

opts = "-E" if rebuild else ""
ctx.run("sphinx-build {} -b html docs dist/docs".format(opts))

if check_links:
linkcheck(ctx, rebuild=rebuild)


@invoke.task()
def linkcheck(ctx, rebuild=False):
"""Check links in documentation."""
print("Running link check...")
opts = "-E" if rebuild else ""
ctx.run("sphinx-build {} -b linkcheck docs dist/docs".format(opts))


ns = Collection(
docs.help,
docs_.help,
check,
lint,
format,
docs.docs,
docs.linkcheck,
docs,
linkcheck,
tests.test,
tests.testdocs,
tests.testcodeblocks,
build.prepare_changelog,
build.clean,
clean,
build.release,
build.build_ghuser_components,
)
Expand Down

0 comments on commit d90b40b

Please sign in to comment.