我有带有对象属性的Python类,它们只被声明为运行构造函数的一部分,如下所示:
class Foo(object):
def __init__(self, base):
self.basepath = base
temp = []
for run in os.listdir(self.basepath):
if self.foo(run):
temp.append(run)
self.availableruns = tuple(sorted(temp))
Run Code Online (Sandbox Code Playgroud)
如果我现在使用help(Foo)或尝试Foo在Sphinx中记录,则不显示self.basepath和self.availableruns属性.这对我们API的用户来说是一个问题.
我已经尝试寻找一种标准方法来确保解析器可以找到这些"动态声明"的属性(最好是docstring'd),但到目前为止还没有运气.有什么建议?谢谢.
我有一个Python项目,它有Sphinx文档和distutils用于发布到Pip.
这两个功能都需要一个版本(例如,0.4b3)
是否有最佳实践可以在需要版本号的各种实用程序中自动维护一致的版本号?
作为奖励,是否有任何与git集成的东西(例如,通过标签)?
我希望sphinx生成类似于doxygen生成的模块概述,这是一个例子
我无法找到狮身人面像如何做到这一点
我可以使用Graphviz生成某种图形,但是我找不到一种方法来获取图形中的可点击对象,其操作方式与上面的示例相同.
是否有任何方法可以直接在sphinx中执行此操作,或者使用某些hack使其作为doxygen模块概述工作?
我有一个图像,我想在github的README.rst文件中对齐,但给出的规格:
.. image:: Logo/PNG/respawn-logo.png
:height: 109 px
:width: 126 px
:scale: 50 %
:alt: respawn
:align: center
Run Code Online (Sandbox Code Playgroud)
不适用于仍处于原始位置且未缩放的图像.有什么理由吗?
我正在做一些非常简单的事情。这是我的Dockerfile:
FROM alpine:latest
ADD hello.sh /bin/hello
RUN chmod +x /bin/hello
CMD /bin/hello
Run Code Online (Sandbox Code Playgroud)
然后我构建图像:
docker build -t hello .
Run Code Online (Sandbox Code Playgroud)
然后我运行图像:
docker run hello
Run Code Online (Sandbox Code Playgroud)
这是输出:
/bin/sh: /bin/hello: not found
Run Code Online (Sandbox Code Playgroud)
为什么会发生这种情况?如果我运行:
docker run hello cat /bin/hello
Run Code Online (Sandbox Code Playgroud)
我可以看到我的脚本内容,这让我更加困惑。
如何在reStructuredText文档中交叉引用索引项?
例如,我如何交叉引用SectionB:
.. index::
pair: SectionA; SectionB
SectionB
--------
SectionB description.
Run Code Online (Sandbox Code Playgroud)
我试着用:ref:'SectionB'和:index:'SectionB',但他们没有工作.
谢谢.
我目前正在将所有现有(不完整)文档迁移到Sphinx.
问题是文档使用Python文档字符串(模块是用C编写的,但可能无关紧要),并且必须将类文档转换为可用于Sphinx的表单.
有sphinx.ext.autodoc,但它会自动将当前文档字符串放到文档中.我想基于当前的文档字符串在(RST)中生成源文件,然后我可以手动编辑和改进.
你会如何将文档字符串转换为Sphinx的RST?
我正在使用Java编写的库来处理几个Jython项目.由于autodoc扩展,我想用Sphinx创建一些好的文档.但是当我尝试创建html时,我得到错误,因为autodoc找不到用Java编写的库:
sphinx-build -b html -d _build/doctrees . _build/html
Running Sphinx v1.0.5
loading pickled environment... done
building [html]: targets for 1 source files that are out of date
updating environment: 0 added, 1 changed, 0 removed
reading sources... [100%] index
/Users/myName/myJythonProject/doc/index.rst:14: (WARNING/2)
autodoc can't import/find module 'myJythonProject', it reported error:
"global name 'PoolManager' is not defined",
please check your spelling and sys.path
Run Code Online (Sandbox Code Playgroud)
其中PoolManager是Java类.
任何人都可以帮我解决这个问题吗?
我正在使用Docbook 5(docbook-xsl-ns),使用Apache FOP生成PDF,我想将所有文本移到左侧.我该怎么做?
源XML是:
<section>
<title>Usage</title>
<programlisting>mvn archetype:generate -DarchetypeGroupId=cz.csob.javor -DarchetypeArtifactId=javor-archetypes-subcomponent -DarchetypeVersion=X.Y.Z</programlisting>
<para>During the subcomponent project generation you will be asked for the following properties:</para>
<itemizedlist>
<listitem>
<para><emphasis>parent-component-id</emphasis> - ID of the parent component, should be the name of the directory the parent component project is placed in</para>
</listitem>
<listitem>...
Run Code Online (Sandbox Code Playgroud)

谢谢.
我目前正在使用Sphinx和autodoc插件为我的python包编写文档.对于函数返回值,我可以写例如:returns: int: count,告诉sphinx存在类型为int的返回值,命名为count.
我现在有一个函数,它让我的数据库中的项目的前辈:
def get_previous_release(release_id):
""" Holt Vorgängeritem eines Items mit der ID release_id
:param release_id: ID des items für das Release
:type release_id: int
"""
if not isinstance(release_id, int):
raise ValueError('get_previous_release expects an Integer value for the parameter release_id')
try:
release = my_queries.core.get_by_id(release_id)
except IndexError:
raise LookupError('The item with id {} could no be found'.format(release_id))
if 'Alpha-Release' in release.name:
release = AlphaRelease(release.key, release.name, release.state)
elif 'Beta-Release' in release.name:
release = BetaRelease(release.key, release.name, release.state)
elif '-Release' in …Run Code Online (Sandbox Code Playgroud)