readthedocs / sphinx-autoapi

A new approach to API documentation in Sphinx.
https://sphinx-autoapi.readthedocs.io/
MIT License
432 stars 128 forks source link

`duplicate object description` when redefing variable with `if` block #335

Open PerchunPak opened 2 years ago

PerchunPak commented 2 years ago

Especially it is raised when trying generate docs for conf.py in RTD, because RTD modify conf.py.

# conf.py while RTD generating docs
...
html_static_path = ["_static"]
...

###########################################################################
#          auto-created readthedocs.org specific configuration            #
###########################################################################
...
# Add RTD Static Path. Add to the end because it overwrites previous files.
if not 'html_static_path' in globals():
    html_static_path = []
if os.path.exists('_static'):
    html_static_path.append('_static')
...

Sample build from my prod.

PerchunPak commented 2 years ago

I found that error happens here. There is no parse_if method so it is just ignoring if block.

node.test.bool_value() returning result of the statement (see docs).

So, you need to write method parse_if, but what the logic should implement this method? There is two variants:

  1. Ignore all if statements.
  2. if not node.test.bool_value() or node.test.bool_value() is "Uninferable": ignore block. And if not, redef all what in statement.

Before creating PR, I need to solve two problems: what I should return and how redef something. Would be nice if someone give some tip.

PerchunPak commented 2 years ago

I make it work! In some time will make PR.