turned digpkg into a pypi package

This commit is contained in:
2026-01-22 21:35:38 +11:00
parent 6823f64541
commit da59155954
12 changed files with 32 additions and 15 deletions

57
dig/docs.py Normal file
View File

@@ -0,0 +1,57 @@
from .util import *
import os, sys
from rich.console import Console
from textual.app import App, ComposeResult
from textual.widgets import MarkdownViewer, Header, Footer
console = Console()
class DocsApp(App):
TITLE = "Digpkg Docs"
SUB_TITLE = "made with ❤️ by SpookyDervish"
def __init__(self, inital_markdown_path: str):
super().__init__()
self.inital_markdown_path = inital_markdown_path
def compose(self) -> ComposeResult:
with open(self.inital_markdown_path, "r") as f:
markdown = f.read()
yield Header()
yield MarkdownViewer(markdown)
yield Footer()
def docs(args):
check_ground_libs_path()
mineral_path = os.path.join(os.getenv("GROUND_LIBS"), args.mineral_name)
if not os.path.isdir(mineral_path):
console.print(f"[b red]digpkg: can't read docs: the mineral [i]{args.mineral_name}[/] was not found!")
sys.exit(1)
docs_path = os.path.join(mineral_path, "docs")
summary_md_file = os.path.join(mineral_path, "SUMMARY.md")
if args.doc_file != None:
if not os.path.isfile(os.path.join(docs_path, f"{args.doc_file}.md")):
console.print(f"[b red]digpkg: can't read docs: the mineral [i]{args.mineral_name}[/] has no doc file named \"{args.doc_file}\".")
sys.exit(1)
os.chdir(docs_path)
app = DocsApp(f"{args.doc_file}.md")
app.run()
sys.exit(0)
if os.path.isfile(summary_md_file):
os.chdir(mineral_path)
app = DocsApp(summary_md_file)
app.run()
sys.exit(0)
else:
console.print(f"[b red]digpkg: can't read docs: the mineral [i]{args.mineral_name}[/] has no file named SUMMARY.md, please use the [i]--doc-file[/] argument to specify a specific doc to open instead.")
sys.exit(1)