How do I omit the values of variables on Sphinx?

非 Y 不嫁゛ 提交于 2019-11-26 14:47:28

问题


I have some module-level variables that have long and uninteresting values which I would like to exclude from auto-generated documentation. Is there a way to do this?

For example, in my Python source I have something like

#:This is a variable with a log value.
long_variable = "Some really long value that is not really of interest and just kind of gets in the way of reading and understanding what's going on."

and in my Sphinx source I have

.. automodule:: the_module
   :members:

and I want the documentation to omit the variable value.

How do I omit the value of variables on Sphinx? Is there ay way to do this in the Python source for specific variables; can I do it in the Sphinx source either for the whole module or for individual variables?


回答1:


Two solutions I can think of:

  • Use the monkey patch for truncating long variable values suggested in this answer: https://stackoverflow.com/a/25163963/407651.

  • Document the module-level variable using autodata with the annotation option.



来源:https://stackoverflow.com/questions/26026819/how-do-i-omit-the-values-of-variables-on-sphinx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!