On 1 August 2013 21:24, Carl Cerecke <[email protected]> wrote:
> I have a number of draft comments I've made in my rst source. These
> take the form of sidebar directives, with a ":class: comment" option.
>
> In plain docutils, I can strip these out at build time with the
> strip_elements_with_classes option - it works on the node tree, so
> works with any builder.
>
> I can't seem to find the equivalent functionality in sphinx, though it
> seems like the sort of problem that others have come across and solved
> before...
>
> How do I the equivalent of strip_elements_with_classes with sphinx? Or
> is there a better way? I could convert all my comments to use
> ifconfig, but that doesn't seem like a good solution. Perhaps I should
> just write a draft-comment directive....
I solved it (quite simply) by writing my own directive:
class DraftComment(directives.body.Sidebar):
def run(self):
env = self.state.document.settings.env
if env.config.draft:
return directives.body.Sidebar.run(self)
else:
return []
which is a better all-around solution. If I decide that sidebars
aren't the best way to format author comments, then I can just use
something else. And I can easily turn the draft comments off/on with
the custom 'draft' option in conf.py
Cheers,
Carl.
--
You received this message because you are subscribed to the Google Groups
"sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sphinx-users.
For more options, visit https://groups.google.com/groups/opt_out.