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

Usage of Fragment or request improve documentation #94

Closed
seichter opened this issue Mar 13, 2025 · 9 comments
Closed

Usage of Fragment or request improve documentation #94

seichter opened this issue Mar 13, 2025 · 9 comments

Comments

@seichter
Copy link

Just starting with htpy, so maybe this is not a bug but a request to clarify the documentation. I am trying to accumulate a list of option passed on to another partial for a select in a separate call and pass it through. I was trying to use Fragment without success. So I am wondering what I am doing wrong. Following an example I would prefer to have it return the Elements without a wrapping element rather than a str come from render_node.

def partial_units_as_options(
    *,
    units: Sequence[Unit],
    selected_id: int | None = None,
    empty_option: str | None = None,
) -> str:
    options = [
        option(value=u.id, selected=selected_id == u.id if selected_id else False)[
            u.name
        ]
        for u in units
    ]
    if empty_option:
        return render_node(
            [option(selected=selected_id is None)[empty_option]] + options
        )
    return render_node(option)
@susodapop
Copy link

susodapop commented Mar 14, 2025

How have you installed htpy? The addition of Fragment occurred last week but has not been released on Pypi yet, so the docs are out of sync with the latest release.

@pelme
Copy link
Owner

pelme commented Mar 14, 2025

This is the first time I did not make a new release when merging stuff directly. The docs currently describe the Fragment class which does not exist yet in a released version. Once #93 lands I will put out a new release to avoid the confusion!

@seichter
Copy link
Author

I installed it through pip.

(.venv) [hartmut@homeworkstation sdplan]$ cat requirements.txt | grep htpy
htpy==25.2.0

and yes, the import didn't work, though. So I think I just wait for the release then. Thanks.

@jodal
Copy link
Contributor

jodal commented Mar 14, 2025

If you host the docs with readthedocs.org, which is free and supports MkDocs and custom domains, you can easily have a /stable/ that reflects the latest tag and /latest/ that reflects the latest commit.

@pelme
Copy link
Owner

pelme commented Mar 15, 2025

Thanks for the tip! I will take care to release frequently to avoid the docs being out of sync. Will hopefully make a new release today/tomorrow with the fragment updates in #95 . I will not be able to spend time switching the docs to readthedocs right now but that could be a good option in the future!

@pelme
Copy link
Owner

pelme commented Mar 15, 2025

closing this issue for now, sorry for the confusion about the fragment, give it another try with the code from github or from the next release and feel free to open another issue if there is a problem with fragment!

@pelme pelme closed this as completed Mar 15, 2025
@pelme
Copy link
Owner

pelme commented Mar 16, 2025

25.3.0 is out now, install it and see https://htpy.dev/usage/#fragments for details on using fragment!

@susodapop
Copy link

@pelme if you'd like, I can contribute a github action that will publish a new release to Pypi automatically whenever a release is cut on github. This has come in very handy on open source projects I've maintained in the past.

@pelme
Copy link
Owner

pelme commented Mar 17, 2025

Thanks, that would be nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants