autodoc

Docstring inheritance for properties using sphinx's autodoc

爷,独闯天下 提交于 2019-12-11 02:23:10
问题 I have a class like this: class MyBase(object): x = 3 """Documentation for property x""" and another class that inherits it: class MyObj(MyBase): x = 0 When I use sphinx's autodoc to generate documentation, MyObj.x is not documented. Is there any way to inherit the docstring from MyBase.x ? I found DocInherit but since this uses a decorator, it only works for class methods. Any way to do this with properties? 回答1: I found a workaround using the property function: class MyBase(object): _x = 3

Inherited attributes in docstring not displayed

半城伤御伤魂 提交于 2019-12-10 17:23:23
问题 I'm trying to use Sphinx to document one base class and 2 child classes with google style docstring classes. I'm particularly stuggling with inherited attributes: class Base(object): """Base class. Attributes: a (int): one attribute b (int): another one """ def __init__(self): self.a = 3 self.b = 5 class FirstChild(Base): """First Child of Base. Attributes: c (float): child class attribute """ def __init__(self): self.c = 3.1 class SecondChild(Base): """Second Child of Base.""" pass Here is

autoclass and instance attributes

和自甴很熟 提交于 2019-12-10 13:47:38
问题 According to the sphinx documentation, the .. autoattribute directive should be able to document instance attributes. However, if I do:: .. currentmodule:: xml.etree.ElementTree .. autoclass:: ElementTree .. autoattribute:: ElementTree._root Then when building I get an AttributeError: Traceback (most recent call last):etree.ElementTree.ElementTree File "/Volumes/Raptor/Library/Python/2.7/lib/python/site-packages/sphinx/ext/autodoc.py", line 326, in import_object obj = self.get_attr(obj, part)

Using sphinx autodoc for a fabfile

爱⌒轻易说出口 提交于 2019-12-10 04:35:16
问题 Is it possible to use Sphinx autodoc to generate documentation for my fabfile, from the function docstrings? E.g. for a fabfile containing a setup_development task i've tried: .. automodule::fabfile :members: .. autofunction:: setup_development But nothing is generated. fabfile snippet: @task def setup_development(remote='origin', branch='development'): """Setup your development environment. * Checkout development branch & pull updates from remote * Install required python packages * Symlink

Including docstring in Sphinx Documentation

…衆ロ難τιáo~ 提交于 2019-12-09 05:31:20
问题 I'd like to include just the docstring of a specific function in my Sphinx documentation. However there seem to be no options to just display these details without associated class and function definitions using http://sphinx.pocoo.org/ext/autodoc.html I've tried creating a class as outlined in show *only* docstring in Sphinx documentation but I'm not sure how this fits in with the templating. I've also tried the autodoc-process-docstring event handler with no luck. So rather than my

Sphinx autodoc dies on ImportError of third party package

女生的网名这么多〃 提交于 2019-12-08 05:06:41
问题 There's any way to exclude the import part of a module and then document it with sphinx-python? I have a module that imports another package (other different project) and then the sphinx gives this error: """ File "/usr/local/lib/python2.7/dist-packages/Sphinx-1.1.3-py2.7.egg/sphinx/ext/autodoc.py", line 321, in import_object import (self.modname) File "/home/x/GitHub/project/mod_example1.py", line 33, in from other_pck import Klass, KlassStuff ImportError: No module named other_pck """ And

lein-autodoc with Leiningen 2

自作多情 提交于 2019-12-08 02:03:38
问题 I am attempting to use lein-autodoc, because I believe it to be the preferred documentation generator for Clojure. I have added :dev-dependencies [[lein-autodoc "0.9.0"]] to my project definition as per the instructions on the lein-autodoc github page. Running lein deps runs without issue, however lein autodoc fails, claiming that autodoc is not a task. I suspect the issue is that lein-autodoc is set up to work with leiningen 1. However, I'm using leiningen 2. Is there an alternate way I

In Sphinx, how to include docstrings/comments located in a module, but outside of class and methods

妖精的绣舞 提交于 2019-12-07 05:49:39
问题 I have a utils module in my package. It consists of several misc standalone methods that do not require instantiation. I would like to place some generic comments/docstring inside this utils file, such as: import os import json """ Miscellaneous methods that help in <<blah blah>> Does not require explicit instantiation. The following actions can be performed: =============== =============== Action Method =============== =============== Get a :meth:`methoda` Get b :meth:`methodb` """ def

Swagger-PHP for generating JSON file for Swagger-UI

风流意气都作罢 提交于 2019-12-06 08:37:01
问题 I am trying to use Swagger-PHP for generating JSON files , so that I can use it with Swagger-UI for auto documentation. I tried the link :- https://github.com/zircote/swagger-php Also I tried to work around with there documentation at http://zircote.com/swagger-php/installation.html But my hard luck , I am unable to implement it. I am able to install composer correctly. Also the bundle of Swagger-PHP is installed correctly. But the problem is that I am unable to use/understand the test

In Sphinx, how to include docstrings/comments located in a module, but outside of class and methods

你。 提交于 2019-12-05 10:33:40
I have a utils module in my package. It consists of several misc standalone methods that do not require instantiation. I would like to place some generic comments/docstring inside this utils file, such as: import os import json """ Miscellaneous methods that help in <<blah blah>> Does not require explicit instantiation. The following actions can be performed: =============== =============== Action Method =============== =============== Get a :meth:`methoda` Get b :meth:`methodb` """ def methoda(data): "Gets A ..." ... def methodb(data): "Gets B ..." ... As seen above, the docstring has a table