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

feature: Jinja handler #661

Open
pawamoy opened this issue Mar 27, 2024 · 6 comments
Open

feature: Jinja handler #661

pawamoy opened this issue Mar 27, 2024 · 6 comments
Assignees
Labels
feature New feature or request

Comments

@pawamoy
Copy link
Member

pawamoy commented Mar 27, 2024

Is your feature request related to a problem? Please describe.

No standard way to document Jinja templates?

Describe the solution you'd like

I just realized it would be nice to have a handler for documenting and auto-generating docs for Jinja templates.
It would parse the templates and extract information from Jinja comments for macros, filters, tests and context.

Describe alternatives you've considered

Manually written Markdown docs.

Additional context

Would be super useful for handlers themselves!

@pawamoy pawamoy added the feature New feature or request label Mar 27, 2024
@pawamoy pawamoy self-assigned this Mar 27, 2024
@pawamoy
Copy link
Member Author

pawamoy commented Apr 21, 2024

I'm writing comments to the Python handler templates so this might be a good time to think about how to format them for easy retrieval and use.

What kind of information should be retrievable from Jinja templates?

  • available context: variables (name, type, value), functions (name, signature, they're variables too), filters (name, signature), tests (name, signature)
  • declared variables (with set, for example with block assignment)
  • available blocks: whether they are scoped or required, blocks inherited from parent templates
  • available tags (loaded through extensions) and their signature?
  • template inheritance diagrams (extends)
  • template inclusion diagrams (include)
  • template imports diagrams (import)
  • a combination of those? (extends + include?)
  • declared macros, whether they use their caller and how
  • extension-specific: for HTML templates, CSS classes used (and in what elements they are used? to build precise selectors?), or summarized HTML tree (div, h2, p, div, ...)

@pawamoy
Copy link
Member Author

pawamoy commented Apr 21, 2024

Hmm, available context (variables, functions, filters, tests, tags) cannot be fully inferred from static analysis only. But I don't see how we could use dynamic analysis, unless we profile the tool and its code rendering templates (I don't think that's feasible, or that it makes much sense anyway). For a complete list of what's available, template writers might need to document that in the template itself.

@tomchristie

This comment was marked as off-topic.

@pawamoy

This comment was marked as off-topic.

@pawamoy
Copy link
Member Author

pawamoy commented Apr 28, 2024

I'll mark both our comments as off-topic (this issue is really about documenting Jinja templates, not Markdown/HTML (pre-)processing), I hope you won't mind 🙂 Feel free to open a dedicated discussion instead 🙂

@tomchristie
Copy link

Ah yep, understood. 👍🏼

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

No branches or pull requests

2 participants