Skip to content
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

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from
Draft

Website/generator #618

wants to merge 15 commits into from

Conversation

PGijsbers
Copy link
Collaborator

Working on some simple scripts which help generate the website, which will make it easier to add frameworks and pages in the future.

@PGijsbers PGijsbers added Documentation Something needs to be added or fixed in the documentation automation Something could be automated labels Apr 15, 2024
Copy link
Collaborator Author

@PGijsbers PGijsbers left a 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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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>"
Copy link
Collaborator Author

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)

Comment on lines 17 to 21
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)
Copy link
Collaborator Author

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]:
Copy link
Collaborator Author

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:
Copy link
Collaborator Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automation Something could be automated Documentation Something needs to be added or fixed in the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant