update 0.4.4
Python application / build (push) Has been cancelled

- update документация
- промт для ии полу конфигурируемый
This commit is contained in:
Igor20264
2026-09-06 11:04:01 +03:00
parent 638fd38d7f
commit 818a044aa1
26 changed files with 1987 additions and 457 deletions
+111 -1
View File
@@ -33,6 +33,13 @@ CLI (тот же движок)
python -m md2gost --gui
md2gost.exe report.md --type PIS_custom --title title.docx
md2gost.exe report.md --schemes path/to/md2gost.schemes.json
md2gost.exe report.md --styles path/to/md2gost.styles.json
Стили JSON (опционально)
Оверлей поверх пресета типа документа (--type). Файл md2gost.styles.json рядом с .md
или --styles / Настройки → Файлы → «Стили JSON». Меняет поля страницы и параметры
стилей абзацев (Normal, Heading 13, подписи…). В шаблон DOCX стили руками добавлять не нужно.
Подробнее: docs/styles.md.
СИНТАКСИС MARKDOWN
@@ -126,7 +133,12 @@ IDEF0 конвертер не рисует — вставляйте готовы
off — не резать, Word сам переносит.
legacy / caption — режем по оценке высоты в md2gost (может не совпасть с Word).
Промпт для ИИ — Справка → Промпт для ИИ: скопируйте и вставьте в ChatGPT / Cursor / Copilot, затем дайте тему и черновик.
Промпт для ИИ — Справка → Промпт для ИИ: выберите промпт, при необходимости
включите схемы (C4, BPMN, …) кнопками — макросы допишутся в конец — скопируйте
в ChatGPT / Cursor / Copilot, затем дайте тему и черновик.
Документация — Справка → Документация: встроенный просмотр docs/*.md
(вшито в exe; внешняя папка docs/ не обязательна).
"""
SCHEMES_HELP = """СХЕМЫ ДИАГРАММ (PlantUML)
@@ -219,6 +231,7 @@ Mermaid: только Kroki (свой --kroki-url / localhost / kroki.io).
"""
PROMPT_FILES = (
("generate-md.md", "Markdown для md2gost"),
("generate-mirea-report.md", "МИРЭА / ГОСТ (курсовая, практика, ВКР)"),
("generate-pis-custom-report.md", "ПИС — отчёт по практическим работам"),
)
@@ -259,3 +272,100 @@ def load_prompt_catalog() -> list[tuple[str, str, str]]:
if text:
catalog.append((name, title, text))
return catalog
def scheme_prompt_block(scheme) -> str:
"""Format one DiagramScheme for appending to an AI prompt."""
sid = getattr(scheme, "id", "") or ""
title = (getattr(scheme, "title", None) or sid).strip()
lines = [
f"## Схема: {title} (`{sid}`)",
"",
f"Оградка в markdown: ```uml-{sid} или ```{sid}",
"",
]
ai = (getattr(scheme, "ai_prompt", None) or "").strip()
if ai:
lines.append(ai)
lines.append("")
docs = (getattr(scheme, "docs", None) or "").strip()
if docs:
lines.append("Макросы / шпаргалка:")
lines.append(docs)
lines.append("")
return "\n".join(lines).rstrip() + "\n"
def compose_prompt(base: str, schemes: list | None = None) -> str:
"""
Base prompt text plus optional scheme blocks (order preserved).
schemes: iterable of DiagramScheme (or objects with id/title/docs/ai_prompt).
"""
text = (base or "").rstrip()
if not schemes:
return text + ("\n" if text else "")
parts = [text, "", "---", "", "# Дополнение: выбранные схемы диаграмм", ""]
for scheme in schemes:
parts.append(scheme_prompt_block(scheme))
parts.append("")
return "\n".join(parts).rstrip() + "\n"
def docs_search_dirs() -> list[Path]:
dirs: list[Path] = []
here = Path(package_dir())
dirs.append(here / "docs")
dirs.append(here.parent / "docs")
if getattr(sys, "frozen", False):
mei = getattr(sys, "_MEIPASS", None)
if mei:
dirs.append(Path(mei) / "docs")
dirs.append(Path(sys.executable).resolve().parent / "docs")
seen: set[str] = set()
out: list[Path] = []
for path in dirs:
key = str(path.resolve()) if path.exists() else str(path)
if key in seen:
continue
seen.add(key)
out.append(path)
return out
def _doc_title_from_text(filename: str, text: str) -> str:
for line in text.splitlines():
stripped = line.strip()
if stripped.startswith("#"):
return stripped.lstrip("#").strip() or Path(filename).stem
return Path(filename).stem
def load_docs_catalog() -> list[tuple[str, str, str]]:
"""
Return list of (filename, title, text) from the first existing docs/ folder.
README.md first, then other *.md alphabetically.
"""
folder: Path | None = None
for path in docs_search_dirs():
if path.is_dir():
folder = path
break
if folder is None:
return []
files = sorted(p for p in folder.glob("*.md") if p.is_file())
if not files:
return []
readme = [p for p in files if p.name.lower() == "readme.md"]
rest = [p for p in files if p.name.lower() != "readme.md"]
ordered = readme + rest
catalog: list[tuple[str, str, str]] = []
for path in ordered:
try:
text = path.read_text(encoding="utf-8")
except OSError:
continue
catalog.append((path.name, _doc_title_from_text(path.name, text), text))
return catalog