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

Documentation question: unclear on toggles #389

Open
xpe opened this issue Sep 2, 2023 · 7 comments
Open

Documentation question: unclear on toggles #389

xpe opened this issue Sep 2, 2023 · 7 comments

Comments

@xpe
Copy link

xpe commented Sep 2, 2023

Toggles: [foo]

Use [foo] syntax to show or hide something based on a boolean expression foo.

This works on empty attributes:

From reading the documentation on toggles, it seems like it would control the rendering of an element. (In my experience, I don't recall seeing a 'toggle' feature in libraries along the lines of Maud; typically in other libraries I use conditional logic for this purpose.)

Or is it something else?

This issue suggests it is something else. (If so, the documentation's wording could be made clearer for sure.)

@FallBackITA27

This comment was marked as off-topic.

@puetzp
Copy link

puetzp commented Dec 11, 2023

The documentation states that this toggles attributes and classes on elements. It does not toggle the element itself with its respective attributes and elements. You are right that if you wanted to display an element on some conditional logic would use @if .

I have not been using maud for long, but I think the documentation is quite clear on that part.

@xpe
Copy link
Author

xpe commented Dec 12, 2023

To focus our attention on it, here is the current documentation:

Toggles: [foo]

Use [foo] syntax to show or hide something based on a boolean expression foo.

This works on empty attributes:

let allow_editing = true;
html! {
    p contenteditable[allow_editing] {
        "Edit me, I "
        em { "dare" }
        " you."
    }
}

And classes:

let cuteness = 95;
html! {
    p.cute[cuteness > 50] { "Squee!" }
}

@xpe
Copy link
Author

xpe commented Dec 12, 2023

'show or hide something'

To reiterate, it says "Use [foo] syntax to show or hide something based on a boolean expression foo."

Saying something is ambiguous. Does this mean an element? Seems like it could, maybe.

No? That's fine. But this would be extremely easy to clear up.

'toggles attributes and classes on elements'

@puetzp You wrote "The documentation states that this toggles attributes and classes on elements."

That's a nice summary. But, to be clear, no maud documentation I've seen says that verbatim. Did I miss it?

As you are not confused, you may not see it -- I refer you to my "Pay more attention to the confused" section below -- but there is a difference between your summary and the documentation in the place I showed. Small differences matter. It is good to welcome all improvements to documentation.

Feeling clearer months later is little consolation

I will grant that months later, yes, with the benefit of your one-line summary of the documentation, I feel clearer. But that shouldn't be the metric of success here. if someone has to step back and have someone else explain it, then it probably could have been clearer in the first place.

Clarification by saying what a feature does not do

Often documentation is made much better by saying what something does not do. A brief note along the lines of "To be clear, this toggling syntax does not pertain to elements / tags; only to attributes and classes.".

Thought process around documentation

The standards and thought process used for standalone documentation are not identical as writing document inside code, much less code itself. The goals and constraints are quite different. For example, the concepts of 'minimalism' and 'all code is debt' can have tremendous value when writing software. But extra clarity, even some degree of redundancy, serve very useful purposes in documentation.

Comparative expectations

Many templating engines do indeed have ways to toggle elements. I came to Maud looking for it. Like it or not, this becomes part of the user mindset when coming to Maud. It is wise to understand where people are coming from and respond accordingly.

Pay more attention to the confused

Generally speaking, when we hear differing opinions about documentation, we should weigh opinions both from people that think "it is good enough" and those who think it can improved. That said, I like to pay more attention to the confused people when writing documentation. That's how you make it better. Thank them -- think about all the people that won't give any feedback at all.

Why so long?

I have a philosophical bent -- meaning a love of knowledge and reasoning. I care relatively less if people agree with me on this particular issue. I'm more interesting in sharing what I've learned and learning from others. I've observed a lack of appreciation around the human aspects around software, so I speak up when I think I see that happening. It is getting better as more people notice it. (Yes, this is long, but I did organize it into headings.)

@puetzp
Copy link

puetzp commented Dec 12, 2023

Thank you for your thorough excourse on this topic. Since I (admittedly) do not have the same philosophical bent, I am going to take the easy route and basically agree with everything you are saying!

You are right in that it is vital for the documentation to highlight and explain unambiguously how a feature works. I also agree that the "toggling of attributes and classes on elements" feature is a prime example where precisely worded documentation is important since it is such a fundamental feature of this library and one that is, in my opinion, very well implemented and incredibly useful.

I understand that just because I do not have an issue interpreting the documentation does not necessarily mean that this is the case for everyone.

That being said I think a Pull Request that improves the explanation of this feature in the documentation will be more than welcome and appreciated by the maintainer(s)! And it will surely avoid confusion in future users who learn how to use maud as well.

@lambda-fairy
Copy link
Owner

Hi all, I haven't read the full discussion, but I'm happy to review a PR that improves the docs.

@puetzp
Copy link

puetzp commented Jan 4, 2024

Sorry, opened the PR in the wrong repository ... fixed.

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