java - 如何在 Jython 项目中创建基于 Sphinx 的文档?

标签 java python jython python-sphinx

我正在使用用 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

其中 PoolManager 是一个 Java 类。

谁能帮我解决这个问题?

最佳答案

Sphinx 可用于记录 Jython 项目,但 autodoc不适用于用 Java 编写的代码。 autodoc 功能导入并检查 Python 模块。不支持对 Java 类执行相同的操作。

为 Java 实现 autodoc(或类似的东西)似乎是可行的,但必须有人自愿去做。请参阅 Sphinx 作者 Georg Brandl 的评论:https://www.mail-archive.com/sphinx-dev@googlegroups.com/msg03162.html .

我找到了一些关于 a proposed GSoC 2010 project 的信息旨在实现对autodoc的多语言支持。但是根据this blog post ,该项目未完成。开发人员选择从事另一个 GSoC 项目。

sphinx-contrib repository不包含与 autodoc 相关的任何内容。


更新

有一个名为 javasphinx 的新 Sphinx 扩展看起来很有趣。我没有使用过这个扩展,但是根据 the documentation ,它可以从 Java 代码生成 reST 源代码:

The javasphinx-apidoc tool is the counterpoint to the sphinx-apidoc tool within the Java domain. It can be used to generate reST source from existing Java source code which has been marked up with Javadoc-style comments. The generated reST is then processed alongside hand-written documentation by Sphinx.

javasphinx 使用另一个名为 javalang 的库.

PyPI 包:

关于java - 如何在 Jython 项目中创建基于 Sphinx 的文档?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4932337/

相关文章:

java - 如何加载外部java类并调用带参数的方法

python - 为什么需要 processEvents() 才能让 QThread 工作?

python - 避免多个 IF 以确保 Mccabe 复杂性

python - Django模型过滤器比较月份失败

java - 执行公正的程序/脚本性能比较

java - 如何使用 c :out 不转义 JSTL 中的字符

Java 线程池 - 日志中的线程数

java - 每周交替

python - 使用 Jython 和 zxJDBC 进行具有多行值的 SQL INSET

java - 如何从 Java 引发 Jython 异常?