On Wednesday, 20 July 2011 06:39:43 UTC-4, Alastair Dent wrote:
>
>  I need to be able to exclude specific rst files, depending on a built 
> parameter.
>  
> Is there an extension that will enable this?
>

Here's what I've done:

1. In my doc set do something like this:

    .. only::

       .. toctree::
          :hidden:
 
          internal/foo

      Some text that refers to :doc:`foo <internal/foo>`.

2. On my sphinx command line do something like this:

    sphinx-build -t internal input-dir output-dir

3. In my conf.py do something like this:

    if tags.has("internal"):
       exclude_patterns = [ '.build' ]
    else:
       exclude_patterns = [ '.build', '.internal' ]

This seems to work. However, whenever I do a build that doesn't include -t 
internal, I get warnings from the sphinx processor that it can't find the 
files internal/foo.

I /assume/ that this is because even though I'm blocking with .. only::, 
the processor still does a first pass through where it builds all the 
"content" stuff (i.e. tries to find all files/nodes), and /then/ decides 
about what text to drop out.

So, really, all I'm doing here is relying on a system error to not include 
the file in the toc tree (because it's in an excluded dir), and the 
..only:: to block out any text that /refers/ to the file with a 
user-visible link.

This doesn't strike me as optimal -- it would be a very useful feature to 
support conditional inclusion/exclusion of stuff at the "node" level (i.e. 
have conditional toc-trees, conditional file includes, and conditional 
blocks that could wrap around (for example) section headings...

This might, however, depending on how sphinx goes about doing its 
processing, be a non-trivial thing to do.

The right answer might very well be much more simply done with N different 
conf files, N different "contents" files, and a cunningly structured source 
tree to minimize duplication of source outside the conf and contents 
files... 8(

--
Viktor Haag

-- 
You received this message because you are subscribed to the Google Groups 
"sphinx-dev" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sphinx-dev/-/3QlilSqzldAJ.
To post to this group, send email to sphinx-dev@googlegroups.com.
To unsubscribe from this group, send email to 
sphinx-dev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sphinx-dev?hl=en.

Reply via email to