-
-
Notifications
You must be signed in to change notification settings - Fork 132
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
Website/generator #618
base: master
Are you sure you want to change the base?
Website/generator #618
Conversation
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.
Some notes for when I continue on this.
class NavigationItem(NamedTuple): | ||
name: str | ||
url: str | ||
icon: str |
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.
icon: str | |
icon: Path |
|
||
def generate_navigation_for(items: list[NavigationItem], mobile: bool = False) -> str: | ||
# TODO: Add outlink icon | ||
item_template = "<a href=\"URL\" class=\"nav-link nav-icon\">NAME_OR_ICON</a>" |
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.
Use string formatting with variable names to make this less prone to errors if changed (replace
doesn't raise an error if the term doesn't exist in the string)
with open(item.icon, "r") as fh: | ||
icon = fh.read() | ||
|
||
name_or_icon = icon if (mobile or item.icon_only) else item.name | ||
nav_html = item_template.replace("URL", item.url).replace("NAME_OR_ICON", name_or_icon) |
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.
don't load file if it's not used
documentation: str = None | ||
|
||
|
||
def load_framework_definitions(definition_file: Path = Path("official_frameworks.toml")) -> list[Framework]: |
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.
don't read and process in the same function, makes it hard to test
|
||
|
||
def load_footer() -> str: | ||
with open("templates/footer.html", "r") as f: |
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.
replace string with defined constant.
why are some templates in files and others hard-coded?
Working on some simple scripts which help generate the website, which will make it easier to add frameworks and pages in the future.