[docutils:bugs] Re: #459 Invalid circular inclusion warning when including multiple documents from a directive
"Günter Milde" via Docutils-develop <[email protected]>
| Newsgroups | gmane.text.docutils.devel |
|---|---|
| Message-ID | </p/docutils/bugs/459/14c13a0b937e94761ecd8e25848dadc3737e2b5c.bugs@docutils.p.sourceforge.net> |
> I'm not sure the `lines = f.read()` quite works because I don't think that puts it into a nice array of lines for parsing ...
The `lines = f.read()` in my small example is a stub.
The point is, that if you insist on `statemachine.insert_input()` to inject generated lines to the document while parsing it, either use the currently active source or a "fancy description" as second argument, e.g.
def run(self):
name = self.content[0]
self.state_machine.insert_input(
['.. include:: %s' % name], 'mytrickydirective')
return []
This works in 0.18 but I can't tell for 0.17.
---
** [bugs:#459] Invalid circular inclusion warning when including multiple documents from a directive**
**Status:** pending-works-for-me
**Created:** Thu Oct 20, 2022 10:30 PM UTC by Ian Wienand
**Last Updated:** Wed Nov 02, 2022 10:46 AM UTC
**Owner:** nobody
**Attachments:**
- [circular-ref-bug.py](https://sourceforge.net/p/docutils/bugs/459/attachment/circular-ref-bug.py) (1.2 kB; text/x-python)
The recent sphinx release has found what I think is a problem in the circular-reference detection in docutils.
We have a situation where we build a page with a directive that automatically includes a file (readme from a sub-component). In some cases, these readme's might then also include another file (e.g. similar components share a common file about their arguments, etc.). So we have a include hierarchy like
~~~
.. include:: ./component/README.rst
.. include:: common.rst
.. include:: ./component2/README.rst
.. include:: common.rst
~~~
Our directive works by reading the `README.rst` file and then using `self.state_machine.insert_input()`
Our build started failing due a `circular inclusion in "include" directive` which comes from the *second* inclusion of the `common.rst` above. In this situation, I don't believe there is any circular inclusion -- we want the same content included twice; but it is not referencing itself.
I think it has something to do with `self.state.document.include_log` thinking that it has seen `common.rst` before.
I have isolated this down to the smallest example I can think of and attached that; it is also at https://paste.opendev.org/show/brTxHYllHebBIs1wHbfM/
When I run this I get
~~~
$ ./docutils-venv/bin/python3 ./recursive.py
Write combined.rst
Write file1.rst
Write file2.rst
Write common.rst
file1.rst:1: (WARNING/2) circular inclusion in "include" directive:
file1.rst
> file1.rst
~~~
---
Sent from sourceforge.net because [email protected] is subscribed to https://sourceforge.net/p/docutils/bugs/
To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/docutils/admin/bugs/options. Or, if this is a mailing list, you can unsubscribe from the mailing list.