Skip to content

Commit

Permalink
✨ generate subcommand generates all outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
vokimon committed Nov 7, 2024
1 parent bd47e09 commit 8d2c0e2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: 🔧 Build
run: |
legal-text-processor reintegrate indexed-tariff-specific-conditions/??.yaml
legal-text-processor generate indexed-tariff-specific-conditions/
legal-text-processor generate
- name: 📂 Generate Directory Listings
uses: jayanta525/[email protected]
Expand Down
9 changes: 7 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
## Deute tècnic

- [ ] Posar els assets a un subdirectori

- [x] TOC strings (title and link text) as translatable
- [ ] Provar el generat a webforms
- [ ] Reorganitzar per generate generic

- [ ] Moure les operacions de gha a un makefile
- [ ] Fer servir l'acció de notificacio al chat quan falla
- [ ] Integrar l'script d'importació (bash) a l'script python principal
- [ ] Generalitzar la reintegració (processar tots els masters que tenen un template.md)
- [ ] Generalitzar la generació per declarativament definir:
Expand All @@ -12,6 +15,8 @@
- Paràmetres
- [ ] En la extracció comprovar que la numeració és consecutiva

- [x] Posar els assets a un subdirectori
- [x] Fer servir l'acció de notificacio al chat quan falla

## Pending unknowns

Expand Down
29 changes: 16 additions & 13 deletions legaltexts/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,33 +215,36 @@ def reintegrate(translation_yaml: list[Path]):
markdown_file.write_text(content)

@app.command()
def generate(master_path: Path):
def generate():
generate_web_pdf(
master_path=Path('indexed-tariff-specific-conditions'),
output_prefix='web-pdf'
)
generate_webforms_html(
master_path=Path('general-conditions'),
output_prefix='webforms'
)

def generate_web_pdf(master_path: Path, output_prefix: str):
"""Generates a set of deployable files"""
document = master_path.name
output_dir.mkdir(exist_ok=True)
output_template = 'web-pdf-{document}-{lang}.pdf'
for markdown_file in master_path.glob('??.md'):
lang = markdown_file.stem
target = output_dir / output_template.format(
document=document,
lang=lang,
)
output_template = f'{output_prefix}-{document}-{lang}.pdf'
target = output_dir / output_template
step(f"Generating {target}...")
generate_pdf(markdown_file, 'pagedlegaltext.css', target)

@app.command()
def generate_html(master_path: Path):
def generate_webforms_html(master_path: Path, output_prefix: str):
"""Generates a set of deployable files"""
from somutils.testutils import temp_path
document = master_path.name
output_dir.mkdir(exist_ok=True)
output_template = 'webforms-{document}-{lang}.html'
for markdown_file in master_path.glob('??.md'):
lang = markdown_file.stem
target = output_dir / output_template.format(
document=document,
lang=lang,
)
output_template = f'{output_prefix}-{document}-{lang}.html'
target = output_dir / output_template
step(f"Generating TOC")
markdown_content = markdown_file.read_text()
toc = generate_toc(markdown_content, top_level = 2)
Expand Down

0 comments on commit 8d2c0e2

Please sign in to comment.