Prevent documentation of infinite loops

74 views
Skip to first unread message

József Pohl

unread,
Jul 22, 2019, 4:57:46 AM7/22/19
to sphinx-users
Hi,

My sphinx generator worked fine until I added an infinite loop to the code. It should only exit on key press which makes sphinx run in an infinite loop and it can be terminated only by killing the process.
Can you please advise a workaround for this? Is there an option to tell sphinx that it should ignore discovering "while true" loops?

Regards
Joe

Peter Burdine

unread,
Jul 30, 2019, 4:34:17 PM7/30/19
to sphinx-users
I don't believe Sphinx (by default) uses while loops.  Are you writing your own extension or using an installed extension?  We've had an issue like this in the past when using jinja.  Is that what you are talking about?

József Pohl

unread,
Jul 30, 2019, 9:05:15 PM7/30/19
to sphinx-users
Sorry, my bad. I was not clear.
So the problem is that my code is documented with sphinx, and if my code contains an infinite while loop, then the documentation generator tries to discover all function calls, so starts running my infinite loop, which makes it run continuously without result. I use the settings of the basic example (documentation makefile etc). No plugins used or anything complicated.
Again: sphinx is working fine on ordinary codes. The problem is when the code contains some surprise in the form of infinite loops.
My current workaround is a stream editor before calling sphinx, which replaces all "while True" with " while False". But I hope there is a better solution.

Peter Burdine

unread,
Jul 30, 2019, 9:57:44 PM7/30/19
to sphinx-users
Is your code protected by:

if __name__ == "__main__":
    main()

If you dont have something like this, your code will be executed when the files are exec'd to get the doc strings.

--
You received this message because you are subscribed to a topic in the Google Groups "sphinx-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sphinx-users/DYikQD3IO5A/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sphinx-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sphinx-users/df1fe68e-83cf-411d-9cf9-c5faa5da5a51%40googlegroups.com.

lebert david

unread,
Jul 31, 2019, 2:01:22 PM7/31/19
to sphinx-users
wat if gitbub pad file under coveer htttp://dave 5000 github.com wordking ederse ....!

Jacob Stevens-Haas

unread,
Aug 6, 2019, 1:20:32 PM8/6/19
to sphinx-users
As Peter Berdine says.  You may also be interested in the halting problem.  It is impossible to tell from an arbitrary while loop whether or not it is infinite.

On Tuesday, July 30, 2019 at 6:57:44 PM UTC-7, Peter Burdine wrote:
Is your code protected by:

if __name__ == "__main__":
    main()

If you dont have something like this, your code will be executed when the files are exec'd to get the doc strings.

On Tue, Jul 30, 2019, 13:34 Peter Burdine <pbur...@gmail.com> wrote:
I don't believe Sphinx (by default) uses while loops.  Are you writing your own extension or using an installed extension?  We've had an issue like this in the past when using jinja.  Is that what you are talking about?

On Monday, July 22, 2019 at 1:57:46 AM UTC-7, József Pohl wrote:
Hi,

My sphinx generator worked fine until I added an infinite loop to the code. It should only exit on key press which makes sphinx run in an infinite loop and it can be terminated only by killing the process.
Can you please advise a workaround for this? Is there an option to tell sphinx that it should ignore discovering "while true" loops?

Regards
Joe

--
You received this message because you are subscribed to a topic in the Google Groups "sphinx-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sphinx-users/DYikQD3IO5A/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sphinx...@googlegroups.com.

József Pohl

unread,
Aug 16, 2019, 5:23:41 AM8/16/19
to sphinx-users
Thank you very much gentleman, this solved my issue.
Reply all
Reply to author
Forward
0 new messages