Skip to content

Generate rst files per data file #35

@danwos

Description

@danwos

First of all, thanks for this great extension.

I'm searching for a way to generate the rst-files based on data files I have.
So for each data file, I would like to get automatically a rst file, which uses .. datatemplate:: to combine the data with a given template.

Benefit: I do not need to create rst-files. A new data file is enough to get it to the documentation.

Is that feature something, datatemplates is allowed to provide?
Or is it maybe out of scope?

I maybe find some time to help with the realisation.
But no promises, you know, christmas/new year chaos :)

This is also related to #4.

Technical realisation proposal

In conf.py a config parameter is needed:

datatemplates_imports = [{
  'path: 'data/my_users/', 
  'template': 'my_template', 
  'target': 'my_content/'  ,
  'csvheader': 'optional',
  'csvdialect': 'optional' },
  {...}
]

Then for each data-file in path, a rst-file is generated inside target, where the file name is the data-file-name + ".rst".

The generated rst-files have a single, configured .. datatemplate:: in it, so that the further build process keeps as it is:
E.g. my_content/petra.rst

.. datatemplate::
   :source: data/my_users/petra.json
   :template: my-template
   :csvheader: if given
   :csvdialect: if given

The user can then reference to the data for instance like this:

.. toctree::
   :glob:

   my_content/*

After the build process, the target folder should be cleaned, so that the rst-files get regenerated with each new build and nobody tries to modify them directly (may be deactivated via config).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions