Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ run commands like this::

invoke inv https://cratedb.com/docs/crate/reference/en/latest/objects.inv
invoke allinv --format=markdown
invoke allinv --format=html+table


Contributing
Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
invoke<3
pueblo[sphinx] @ git+https://github.com/pyveci/pueblo.git@amo/sphinx
sphinx<8
linksmith==0.0.1
26 changes: 8 additions & 18 deletions tasks.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# Tech Writing support.
# https://docs.pyinvoke.org/en/stable/getting-started.html
from pathlib import Path
import shlex
import subprocess

from invoke import task
import typing as t

from pueblo.sphinx.inventory import SphinxInventoryDecoder


@task
def inv(c, url: str, format: t.Literal["text", "markdown"] = "text"):
def inv(c, url: str, format_: str = "text"):
"""
Display intersphinx inventory for individual project, using selected output format.

Expand All @@ -18,19 +16,12 @@ def inv(c, url: str, format: t.Literal["text", "markdown"] = "text"):
invoke inv https://cratedb.com/docs/crate/reference/en/latest/objects.inv
invoke inv https://cratedb.com/docs/crate/reference/en/latest/objects.inv --format=markdown
"""
name = Path(url).parent.parent.parent.name
inventory = SphinxInventoryDecoder(name=name, url=url)
if format == "text":
inventory.as_text()
elif format == "markdown":
inventory.as_markdown(omit_documents=True)
#inventory.as_markdown(labels_only=True)
else:
raise NotImplementedError(f"Output format not implemented: {format}")
cmd = f"linksmith inventory {url} --format={format_}"
subprocess.check_call(shlex.split(cmd))


@task
def allinv(c, format: t.Literal["text", "markdown"] = "text"):
def allinv(c, format_: str = "text"):
"""
Display intersphinx inventory for all projects, using selected output format.

Expand All @@ -39,6 +30,5 @@ def allinv(c, format: t.Literal["text", "markdown"] = "text"):
invoke allinv
invoke allinv --format=markdown
"""
urls = Path("./registry/sphinx-inventories.txt").read_text().splitlines()
for url in urls:
inv(c, url, format)
cmd = f"linksmith inventory https://github.com/crate/crate-docs/raw/main/registry/sphinx-inventories.txt --format={format_}"
subprocess.check_call(shlex.split(cmd))