I'm trying to understand sphinx, and I'm thoroughly not understanding how 
to implement even some basic concepts. I've created a sphinx project linked 
to my readthedocs account. Everything works to generate my basic index.rst 
file in read the docs. I'm trying to follow the ideas of adding dynamic 
input to a specific page within my project, as mentioned 
here: http://ericholscher.com/blog/2016/jul/25/integrating-jinja-rst-sphinx/

My objective is to setup my sphinx project so that whenever a specific text 
file changes in my /docs folder, it updates my ReadTheDocs content 
dynamically/automatically.

My /docs folder has these key elements:

parsethisfile.txt
conf.py
index.rst
Database.rst
...

In my conf.py I've added some python which parses a txt file, and then 
creates references to the object:

def rstjinja(app, docname, source):
    """
    Render our pages as a jinja template for fancy templating goodness.
    """
    # Make sure we're outputting HTML
    if app.builder.format != 'html':
        return
    src = source[0]
    rendered = app.builder.templates.render_string(
        src, app.config.html_context
    )
    source[0] = rendered

def setup(app):
    app.connect("source-read", rstjinja)

html_context = {
    #'outputschema': schema_list_out
}

The "schema_list_out" is a list (or I could make a dictionary) which 
contains elements for a database schema, such as table names, comments, 
column names and column parameters.

If I wanted to generate dynamic ReadTheDocs pages, I've successfully been 
able to add some variables to my Database.rst file like this:
{% for schema_item in outputschema %}
**Schema Name: {{ schema_item["name"] }}**
{% endfor %}
and sphinx correctly creates a Database.html file that shows this:

Schema Name: buildings

More importantly, I'm trying to create nice looking tables for the items in 
my "schema_list_out" list. The only way I've been able to do that is using 
the python tabulate module (in my conf.py), where I generate the table 
within python, output as rst, and save it as a list element object within 
my "schema_list_out". If I use the right control structure in my rst, I 
generate a nice looking table in rst format that looks correct in my sphinx 
generated output:

<https://lh3.googleusercontent.com/-dhpbPBXkgwQ/Wrsp8EOcAWI/AAAAAAAAF2E/kU8XMyxpMEs6H_aeDuEsNQ6DN9XEthTMACLcBGAs/s1600/schema2.png>
But the problem here is I have no way of controlling how this looks inside 
the rst file because it's RST, and I can't add HTML, css or anything else 
to control how the table looks (like table width, color etc). reST markup 
doesn't seem to offer enough control over a table.
How do I create dynamically created tables which can be formatted nicely, 
in RST? If I could create the tables easily in my Database.html, I'd do 
that, but it's not a template, it's generated by sphinx from my 
Database.rst. I can't figure out how to create my Database.html myself, 
with the jinja control structures inside of it. How do do that?




-- 
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 sphinx-users+unsubscr...@googlegroups.com.
To post to this group, send email to sphinx-users@googlegroups.com.
Visit this group at https://groups.google.com/group/sphinx-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to