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
7 changes: 7 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ jobs:
- name: Check API Doc Coverage
run: |
interrogate pyadm1
- name: Fix Markdown List Line Endings
run: |
python pyadm1/utils/fix_markdown_lists.py docs
- name: Generate Skill.md for LLMs
run: |
export PYTHONPATH=$PYTHONPATH:.
python pyadm1/utils/generate_skill_md.py

- name: Generate Changelog
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
Expand Down
3 changes: 3 additions & 0 deletions docs/de/user_guide/llm_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

Diese Seite bietet eine strukturierte Referenz der Methoden und Klassen, die benötigt werden, um ein PyADM1ODE-Simulationsmodell automatisch zu erstellen. Diese Dokumentation ist darauf optimiert, von Large Language Models (LLMs) gelesen zu werden, um Biogasanlagenkonfigurationen zu generieren.

!!! abstract "Skill für LLMs"
Sie können die vollständige API-Dokumentation für LLMs als "Skill"-Datei hier herunterladen: [Skill.md](Skill.md)

## Kern-Workflow

Um eine Simulation zu erstellen, folgen Sie diesem Ablauf:
Expand Down
3 changes: 3 additions & 0 deletions docs/en/user_guide/llm_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

This page provides a structured reference of the methods and classes required to automatically create a PyADM1ODE simulation model. This documentation is optimized for reading by Large Language Models (LLMs) to generate biogas plant configurations.

!!! abstract "Skill for LLMs"
You can download the full API documentation for LLMs as a "Skill" file here: [Skill.md](Skill.md)

## Core Workflow

To create a simulation, follow this sequence:
Expand Down
42 changes: 42 additions & 0 deletions pyadm1/utils/fix_markdown_lists.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import os
import re
import sys


def fix_markdown_file(filepath):
with open(filepath, "r", encoding="utf-8") as f:
lines = f.readlines()

modified = False
new_lines = []

# Pattern for markdown lists: starts with -, *, +, or 1., 2. etc.
list_pattern = re.compile(r"^(\s*)([-*+]|\d+\.)\s+")

for line in lines:
stripped_line = line.rstrip("\n")

# Check if it's a list item and doesn't already end with two spaces
if list_pattern.match(stripped_line):
if not stripped_line.endswith(" "):
stripped_line = stripped_line.rstrip() + " "
modified = True

new_lines.append(stripped_line + "\n")

if modified:
with open(filepath, "w", encoding="utf-8") as f:
f.writelines(new_lines)
print(f"Fixed lists in: {filepath}")


def main(directory):
for root, dirs, files in os.walk(directory):
for file in files:
if file.endswith(".md"):
fix_markdown_file(os.path.join(root, file))


if __name__ == "__main__":
target_dir = sys.argv[1] if len(sys.argv) > 1 else "docs"
main(target_dir)
53 changes: 53 additions & 0 deletions pyadm1/utils/generate_skill_md.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import inspect
import os
from pyadm1.substrates.feedstock import Feedstock
from pyadm1.configurator.plant_builder import BiogasPlant
from pyadm1.configurator.plant_configurator import PlantConfigurator
from pyadm1.components.mechanical.pump import Pump
from pyadm1.components.mechanical.mixer import Mixer
from pyadm1.components.feeding.substrate_storage import SubstrateStorage
from pyadm1.components.feeding.feeder import Feeder


def get_full_doc(obj):
doc = inspect.getdoc(obj)
if not doc:
return "No documentation available."
return doc


def generate_skill_md(output_path):
classes_to_document = [Feedstock, BiogasPlant, PlantConfigurator, Pump, Mixer, SubstrateStorage, Feeder]

content = "# PyADM1ODE Simulation Model Creation Skill\n\n"
content += "This document provides the full API documentation for the classes and methods required to build a PyADM1ODE biogas plant simulation model.\n\n"

for cls in classes_to_document:
content += f"## {cls.__name__}\n\n"
content += f"```python\n{cls.__name__}\n```\n\n"
content += f"{get_full_doc(cls)}\n\n"

methods = [
m for m in inspect.getmembers(cls, predicate=inspect.isroutine) if not m[0].startswith("_") or m[0] == "__init__"
]

if methods:
content += f"### Methods for {cls.__name__}\n\n"
for name, func in methods:
try:
sig = str(inspect.signature(func))
except (ValueError, TypeError):
sig = "(...)"
content += f"#### {name}\n\n"
content += f"```python\n{name}{sig}\n```\n\n"
content += f"{get_full_doc(func)}\n\n"

os.makedirs(os.path.dirname(output_path), exist_ok=True)
with open(output_path, "w", encoding="utf-8") as f:
f.write(content)
print(f"Generated Skill.md at: {output_path}")


if __name__ == "__main__":
generate_skill_md("docs/en/user_guide/Skill.md")
generate_skill_md("docs/de/user_guide/Skill.md")
Loading