Well, I found a solution here <https://gist.github.com/3768206> :
class *CheckboxDirective*(SphinxDirective):
has_content = True
def run(self):
targetid = 'checkbox-%d' % self.env.new_serialno('checkbox')
targetnode = nodes.target('', '', ids=[targetid])
checkbox_node = checkbox(self.content)
self.state.nested_parse(self.content, self.content_offset,
checkbox_node)
return [targetnode, checkbox_node]
def *html_checkbox*(self, node):
template= """
<div class=\"checkbox\"><input type=\"checkbox\" ><label>
%(content)s
</label></div>
"""
print(str(node))
self.body.append(template%{'content':str(node)})
raise nodes.SkipNode
[...]
def *setup*(app):
app.add_config_value('include_checkbox', False, 'html')
app.add_node(checkbox,
html=(html_checkbox, depart_checkbox_node)
app.add_directive('checkbox', CheckboxDirective)
app.connect('doctree-resolved', process_checkbox_nodes)
app.connect('env-purge-doc', purge_cbs)
return {'version' : '0.1'} # identifies the version of our extension
Hope it helps someone :)
Carlos
El viernes, 20 de septiembre de 2019, 17:33:45 (UTC+2), Carlos R escribió:
>
> Hi you all,
>
> I am willing to create an Sphinx Extension that recognizes the directive
> * .. checkbox:: some_text_here_for_the_item *
>
> in order to create a html checkbox preceding the text in the page.
>
> I followed this tutorial (
> https://www.sphinx-doc.org/en/master/development/tutorials/todo.html) and
> managed to have this (code .py attached):
>
>
> 4. Checkboxes
> ----------------------
> .. checkbox:: item 1
> .. checkbox:: item 2
> .. checkbox:: item 3
>
>
> [image: Capture.PNG]
>
>
>
>
>
>
>
>
>
>
>
>
>
> The thing that I would like to have is every element in a line in a single
> line, and not that
>
> Could someone tell me if there would be a way of modifying the way sphinx
> represents the nodes of each directive ?
> Do you have any other workaround ?
>
> Thank you and have a great day !
>
> Carlos
>
>
>
>
>
>
El viernes, 20 de septiembre de 2019, 17:33:45 (UTC+2), Carlos R escribió:
>
> Hi you all,
>
> I am willing to create an Sphinx Extension that recognizes the directive
> * .. checkbox:: some_text_here_for_the_item *
>
> in order to create a html checkbox preceding the text in the page.
>
> I followed this tutorial (
> https://www.sphinx-doc.org/en/master/development/tutorials/todo.html) and
> managed to have this (code .py attached):
>
>
> 4. Checkboxes
> ----------------------
> .. checkbox:: item 1
> .. checkbox:: item 2
> .. checkbox:: item 3
>
>
> [image: Capture.PNG]
>
>
>
>
>
>
>
>
>
>
>
>
>
> The thing that I would like to have is every element in a line in a single
> line, and not that
>
> Could someone tell me if there would be a way of modifying the way sphinx
> represents the nodes of each directive ?
> Do you have any other workaround ?
>
> Thank you and have a great day !
>
> Carlos
>
>
>
>
>
>
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/sphinx-users/d14e8c85-4680-43e9-85c7-2725eb2254a6%40googlegroups.com.