On 2011-11-07, Alex Wilkie wrote: ...
> I am putting lots of repeated rst in files that I am "including" in > the actual source rst for a given file that I am documenting. As these > files that need to be documented there is a lot of duplicated class > attributes that have different prefixes - an example is probably > clearer! > [generic.rst] > .. attribute: |prefix|_my_attr > this is the |prefix|_my_attr dox > [file1.rst] > .. |prefix| replace:: foo > .. include:: generic.rst > .. |prefix| replace:: bar > .. include:: generic.rst > I'm hoping this would result in nice formatted replaced text in the > result of file1 something like: > .. attribute: foo_my_attr > this is the foo_my_attr dox > .. attribute: bar_my_attr > this is the bar_my_attr dox > But instead I get multi replace definition errors... This is Docutils (current) behaviour, it ensures you do not accidentially overwrite a substitution reference in one document. The "include" directive "embeds" the included file before parsing, so it is equivalent to placing the file content inline. It should, however, be possible to have *separate* documents, all including generic.rst and setting different replacements. I don't know if this also works for separate documents that are interlinked via the Sphinx toc. (I guess it works with HTML and fails with LaTeX.) > Does this make anysense to anyone? Is it currently possible? How would > I go about writing a custom directive to achieve it? Writing a custom directive would be quite "invasive": it would require changes in the way substitutions are done. The Docutils developer documentation and the Docutils source will give hints. Günter -- You received this message because you are subscribed to the Google Groups "sphinx-dev" group. 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.