-
Notifications
You must be signed in to change notification settings - Fork 0
Support for AsciiDoc template generation #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The AsciiDoc template generation system mirrors the HTML system. We reuse existing infrastructure, using the same data source builder and validation as the HTML templates, ensuring consistency. - Template environment setup in `dqgen/services/__init__.py` - New AsciiDoc generator service `asciidoc_generator.py` - New AsciiDoc template generator service `asciidoc_templates_generator.py` - New CLI entrypoint for the new service - New Make target The generator reuses `template_builder.build_html_template()` (same parameters, different template content). Example run, for the OWL AP: ```sh make generate_asciidoc_templates ap=dqgen/resources/aps/owl-core.csv output=./output ``` Thanks to CursorAI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| def generate_asciidoc_template(processed_csv_file: pd.DataFrame, asciidoc_output_folder_path, template, file_name): | ||
| """ | ||
| Builds an AsciiDoc page and puts into a specified folder | ||
| :param file_name: | ||
| :param template: | ||
| :param processed_csv_file: | ||
| :param asciidoc_output_folder_path: | ||
| :return: | ||
| """ | ||
|
|
||
| data_source = build_datasource_for_html_template(processed_csv_file=processed_csv_file) | ||
| build_template = template.stream(data_source=data_source) | ||
| build_template.dump(asciidoc_output_folder_path + "/" + file_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Build data source with HTML file extensions
The AsciiDoc generator calls build_datasource_for_html_template, which always produces include paths ending in .html. However AsciiDocGenerator writes the class/property fragments with the .adoc extension. The generated main.adoc and statistics.adoc will therefore try to {% include %} .html files that do not exist, leaving the report empty. The data source needs to emit .adoc file names (or a variant of the builder that accepts the target extension) so the include paths match the files produced.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed by refactoring the datasource builder
costezki
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is place for improvement, but we shall proceed to save time.
The query files inserted within the AsciiDoc templates appeared to be HTML files. Add a `file_extension` parameter to produce whatever file extension is needed, currently either `.html` or `.adoc`. Update/add tests accordingly so such accidents can be captured in the future.
The AsciiDoc template generation system mirrors the HTML system. We reuse existing infrastructure, using a refactored data source builder and validation similar to the HTML templates, ensuring consistency.
dqgen/services/__init__.pyasciidoc_generator.pyasciidoc_templates_generator.pyExample run, for the OWL AP:
Thanks to CursorAI & VSCode Copilot.