I’ll try to briefly explain how things work:
Jinja2 is the template engine, which takes files and renders them by replacing stuff inside {{ }} and interpreting macros inside {% %} (things like for loops and such).
Sphinx uses Jinja in such a way that, given a set of html templates comprising a theme and the documentation information, it renders everything as a static website.
Also note that Sphinx extensions which render some custom html (for example, the image directive), do not use Jinja2, rather the extension itself spits out html code on render. This might be closer to what you want.
Tinkerer uses Jinja in two ways: one, through Sphinx – Tinkerer has a custom set of themes different than Sphinx, so we can have html5 support and a bunch of other neat blog-related things; two – Tinkerer also uses Jinja for post and page templates, so when you create a new post, we actually have a post.rst template and we use Jinja to render it.
If you want the post, by default, to contain an additional directive, you can create a custom post.rst template in your blog’s _template subdir so when Tinkerer creates a new post docunment for you, you get the directive auto-included. You can specify this in the documentation, and provide your poist.rst template with the extension, so users consuming your extension can create the same setup.
In terms of your extension/directive rendering itself as html, you don’t need to worry about theming, just make sure that the extension itself knows how to render itself as html. An example of that is the readmore extension in tinkerer/ext/readmore.py.
In short, if you want your extension to introduce a new directive, say mydirective, then in the implementation of that directive, you have to write the code that renders it as html. Then when Sphinx builds a post containing that directive, it will call the function that will give your directive the chance to render itself as html. Independent of that, you can extend post.rst template to always include the directive, so new posts always contain mydirective upon creation.
A change that would require altering themes is more intrusive than that, so I hope you don’t really need it. I’m reserving that for core functionality. Things like post timestamp, author, and tags, which are required by any blog, belong in that category, but not much else.
Thank you,
Vlad
--
You received this message because you are subscribed to the Google Groups "tinkerer-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tinkerer-dev...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.