Skip to content

Commit

Permalink
Add Golang flavor + clean up README.md update
Browse files Browse the repository at this point in the history
  • Loading branch information
haimkastner committed Dec 4, 2024
1 parent 72ba7f5 commit d84708b
Show file tree
Hide file tree
Showing 7 changed files with 409 additions and 565 deletions.
395 changes: 11 additions & 384 deletions README.md

Large diffs are not rendered by default.

378 changes: 378 additions & 0 deletions Units.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions units_generator/generate_package.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from common.fetch_units_definitions import get_definitions
from generators.generate_unit_class import unit_class_generator
from generators.generate_export import export_generator
from generators.generate_readme import readme_generator
from generators.generate_docs import units_docs_generator

print("Starting generating python units...")

Expand All @@ -16,6 +16,6 @@
export_generator(definitions)

# Generate README doc file
readme_generator(definitions)
units_docs_generator(definitions)

print("Generating python units package finished successfully")
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from typing import List

from jinja2 import Template, StrictUndefined
from templates import readme_template
from templates import docs_template


def readme_generator(definitions: List):
def units_docs_generator(definitions: List):
template_methods = []

for definition in definitions:
Expand All @@ -20,12 +20,12 @@ def readme_generator(definitions: List):
template_data = {"methods": template_methods}

# Create a Jinja2 template object
template = Template(readme_template, undefined=StrictUndefined)
template = Template(docs_template, undefined=StrictUndefined)

# Render the template with the data
code = template.render(template_data)

with open(f"README.md", "w", encoding="utf-8") as f:
with open(f"Units.md", "w", encoding="utf-8") as f:
f.write(code)

print(f'[readme_generator] Generating "README.md" finished successfully')
print(f'[units_docs_generator] Generating "Units.md" finished successfully')
6 changes: 3 additions & 3 deletions units_generator/templates/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
export_classes_template = f.read()


readme_template = ""
with open("units_generator/templates/readme_template.jinja2", "r", encoding="utf-8") as f:
readme_template = f.read()
docs_template = ""
with open("units_generator/templates/docs_template.jinja2", "r", encoding="utf-8") as f:
docs_template = f.read()

10 changes: 10 additions & 0 deletions units_generator/templates/docs_template.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
### Supported units

The package provides support for the following units:

{% for method in methods %}
- **{{ method.unit_name }}**
- *{{ method.description }}*
{% endfor %}


171 changes: 0 additions & 171 deletions units_generator/templates/readme_template.jinja2

This file was deleted.

0 comments on commit d84708b

Please sign in to comment.