Giter Site home page Giter Site logo

javasphinx's Introduction

javasphinx

Documentation Status

This project is no longer maintained and should be used for historical purposes only.

javasphinx is an extension to the Sphinx documentation system which adds support for documenting Java projects. It includes a Java domain for writing documentation manually and a javasphinx-apidoc utility which will automatically generate API documentation from existing Javadoc markup.

javasphinx is available in the Python Package Index (PyPi) under the name javasphinx and can be installed using tools such as pip or easy_install.

Documentation for javasphinx is available at http://bronto-javasphinx.readthedocs.io

javasphinx's People

Contributors

andrewd18 avatar balasridhar avatar c2nes avatar gonzoinc avatar manoelcampos avatar moigagoo avatar octag-m avatar sgala avatar vitaut avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

javasphinx's Issues

Add License

Hey,

I'm looking for something that does exactly what this does :) It looks like it's still pretty new, but is it in a workable state?

Also, it would be awesome if you could include a License file in it (preferably BSD/MIT :) so that I might be able to use it.

Cheers,
Eric

Encoding issue running on javasphinx + py3 + windows 10

Hi,

Related to issue #56 and issue #37

On Windows10 javasphinx-apidoc won't work when run on Python 3.6.4. It will if run on Python2.7. This is with javasphinx==0.9.15 for both

It looks like the script, or possibly the python stdlib, are expecting the read files to be encoded in cp1252? But the files are actually utf-8. This will hit a problem on any byte that isn't a valid cp1252 character.

e.g. If trying to read character ๐Ÿ ( U+1F40D, encoded in UTF-8 as b'\xF0\x9F\x90\x8D') then the script throws an exception, as it's treating that as 4 separate characters, and byte 0x90 is not a cp1252 character.

The stack trace shown is:

  File "C:\dev\env\python\Python36\Scripts\javasphinx-apidoc-script.py", line 11, in <module>
    load_entry_point('javasphinx==0.9.15', 'console_scripts', 'javasphinx-apidoc')()
  File "c:\dev\env\python\python36\lib\site-packages\javasphinx\apidoc.py", line 347, in main
    opts.member_headers, opts.parser_lib)
  File "c:\dev\env\python\python36\lib\site-packages\javasphinx\apidoc.py", line 228, in generate_documents
    this_file_documents = generate_from_source_file(doc_compiler, source_file, cache_dir)
  File "c:\dev\env\python\python36\lib\site-packages\javasphinx\apidoc.py", line 191, in generate_from_source_file
    source = f.read()
  File "c:\dev\env\python\python36\lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 24: character maps to <undefined>

Whilst it works in py2, I'm feel like this is purely by accident due to python2's very "liberal" string decoding policies and the fact that it's a UTF-8 file. If my file was encoded in something weird, e.g. EUCJIS/SJIS, then the tool will fail. The official javadoc tool has an encoding option.

It would be good if javasphinx-apidoc could take an --encoding parameter and ensure that all files are read/decoded in that format.

Full Example

This was done using Powershell_ISA to "ensure" that the unicode characters were printed correctly, but it will happen in cmd.exe or git bash etc.

PS C:\dev\work\Mobile-SDK-Android\docs> Get-Content .\java\utf8.java -Encoding UTF8
package java;

/**
 * ๐Ÿ U+1F40D -> \xF0\x9F\x90\x8D
 * ๐Ÿ‘ U+1F450 -> \xF0\x9F\x91\x90
 */
public class EncodingProblems {
    public static void main(String[] args) {
        System.out.println("Hello!");
    }
}

PS C:\dev\work\Mobile-SDK-Android\docs> C:\dev\env\python\Python36\Scripts\javasphinx-apidoc.exe --output-dir=tmp/ java/
C:\dev\env\python\Python36\Scripts\javasphinx-apidoc.exe : Traceback (most recent call last):
At line:1 char:1
+ C:\dev\env\python\Python36\Scripts\javasphinx-apidoc.exe --output-dir ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Traceback (most recent call last)::String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
 
  File "C:\dev\env\python\Python36\Scripts\javasphinx-apidoc-script.py", line 11, in <module>
    load_entry_point('javasphinx==0.9.15', 'console_scripts', 'javasphinx-apidoc')()
  File "c:\dev\env\python\python36\lib\site-packages\javasphinx\apidoc.py", line 347, in main
    opts.member_headers, opts.parser_lib)
  File "c:\dev\env\python\python36\lib\site-packages\javasphinx\apidoc.py", line 228, in generate_documents
    this_file_documents = generate_from_source_file(doc_compiler, source_file, cache_dir)
  File "c:\dev\env\python\python36\lib\site-packages\javasphinx\apidoc.py", line 191, in generate_from_source_file
    source = f.read()
  File "c:\dev\env\python\python36\lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 24: character maps to <undefined>

PS C:\dev\work\Mobile-SDK-Android\docs> C:\dev\env\python\Python27\Scripts\javasphinx-apidoc.exe --output-dir=tmp/ java/

Index error with empty Javadoc comments

A comment like this will break the parsing, reporting a list index out of range. Error output below.

/**
 *
 */

Traceback:

Traceback (most recent call last):
  File "/home/git/rtd/local/lib/python2.7/site-packages/javasphinx/apidoc.py", line 170, in generate_from_source_file
    documents = doc_compiler.compile(ast)
  File "/home/git/rtd/local/lib/python2.7/site-packages/javasphinx/compiler.py", line 303, in compile
    document = self.compile_type_document(import_block, package, name, declaration)
  File "/home/git/rtd/local/lib/python2.7/site-packages/javasphinx/compiler.py", line 208, in compile_type_document
    type_dir = self.compile_type(declaration)
  File "/home/git/rtd/local/lib/python2.7/site-packages/javasphinx/compiler.py", line 82, in compile_type
    doc = self.__output_doc(declaration)
  File "/home/git/rtd/local/lib/python2.7/site-packages/javasphinx/compiler.py", line 38, in __output_doc
    doc = javalang.javadoc.parse(documented.documentation)
  File "/home/git/rtd/local/lib/python2.7/site-packages/javalang/javadoc.py", line 98, in parse
    justified = _left_justify(uncommented)
  File "/home/git/rtd/local/lib/python2.7/site-packages/javalang/javadoc.py", line 85, in _left_justify
    common_indent = indent_levels[0]
IndexError: list index out of range

I realize it's incredibly stupid and ultimately useless to have an empty comment. I deleted them in the source code, but perhaps instead of failing fatally it should produce a warning with line number and file name (if it knows it).

Exclude files as well as paths

I'm using Javasphinx with a Play! framework project. Play requires the use of a Global.java file, which I want to ignore. I can't do that unless I put that in a directory to exclude. I don't think this can be done using the exclude path optional argument, as it didn't work for me. Would be nice though.

python3 Sphinx v1.4.4 error!

Running Sphinx v1.4.4

Extension error:
Could not import extension javasphinx (exception: No module named 'domain')

Object arrays are formatted without square brackets []

Consider the following example:

package test;

class Test {
  void f(Object[] args) {}
}

javasphinx produces the following RST output for the f method:

.. java:method::  void f(Object args)
   :outertype: Test

Note missing square brackets in the type of args. Should be Object[] instead of Object.

Version 0.9.9 is released, but no tag exists

Not a biggie, but tags stop at 0.9.8.

sgala@axolotl:~/Code/javasphinx$ git tag 
javasphinx-0.9.0
javasphinx-0.9.1
javasphinx-0.9.2
javasphinx-0.9.3
javasphinx-0.9.4
javasphinx-0.9.5
javasphinx-0.9.6
javasphinx-0.9.7
javasphinx-0.9.8
sgala@axolotl:~/Code/javasphinx$ grep version setup.py 
version = "0.9.9",

ImportError: No module named 'domain'

Javasphinx do not work on Python3 for me.

I use a virtual environnement:

$pyvenv venv
$source venv/bin/activate

I am actually on Python3:

$python -V
Python 3.4.3+

I installed javasphinx successfully:

$ pip install javasphinx
Successfully installed javasphinx javalang lxml beautifulsoup4 six

This is the installed packages:

$ pip freeze
beautifulsoup4==4.5.1
javalang==0.10.0
javasphinx==0.9.13
lxml==3.6.4
six==1.10.0

And this is the result of javasphinx-apidoc command (no matter the arguments I use):

$javasphinx-apidoc
Traceback (most recent call last):
  File "/home/nathanael/zest-writer/doc/vv/bin/javasphinx-apidoc", line 9, in <module>
    load_entry_point('javasphinx==0.9.13', 'console_scripts', 'javasphinx-apidoc')()
  File "/home/nathanael/zest-writer/doc/vv/lib/python3.4/site-packages/pkg_resources/__init__.py", line 558, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/home/nathanael/zest-writer/doc/vv/lib/python3.4/site-packages/pkg_resources/__init__.py", line 2682, in load_entry_point
    return ep.load()
  File "/home/nathanael/zest-writer/doc/vv/lib/python3.4/site-packages/pkg_resources/__init__.py", line 2355, in load
    return self.resolve()
  File "/home/nathanael/zest-writer/doc/vv/lib/python3.4/site-packages/pkg_resources/__init__.py", line 2361, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/home/nathanael/zest-writer/doc/vv/lib/python3.4/site-packages/javasphinx/__init__.py", line 17, in <module>
    from domain import JavaDomain
ImportError: No module named 'domain'

I then tryed with a Python2 virtual env. and it works.

It's related to this line (I don't know why the init file don't see the domain module.).

System: Ubuntu 15.10

javasphinx-apidoc throws an error when a file contains only commented code

javasphinx-apidoc throws an error when a file contains only commented code.

javasphinx-apidoc -o javasphinx ~/svn/trunk/
ERROR:root:Unexpected exception while compiling <path to file with only commented code>
Traceback (most recent call last):
  File "/usr/lib/python3.5/site-packages/javasphinx/apidoc.py", line 190, in generate_from_source_file
    documents = doc_compiler.compile(ast)
  File "/usr/lib/python3.5/site-packages/javasphinx/compiler.py", line 323, in compile
    raise ValueError('File must have package declaration')
ValueError: File must have package declaration

javasphinx-apidoc breaks with unknown variable

https://github.com/bronto/javasphinx/blob/master/javasphinx/apidoc.py#L142

is then tried to be used here, but doesn't exist, if there's no cache dir:

https://github.com/bronto/javasphinx/blob/master/javasphinx/apidoc.py#L158

  File "/Users/eric/.virtualenvs/readthedocs/bin/javasphinx-apidoc", line 8, in <module>
    load_entry_point('javasphinx==0.9.7', 'console_scripts', 'javasphinx-apidoc')()
  File "/Users/eric/.virtualenvs/readthedocs/lib/python2.6/site-packages/javasphinx/apidoc.py", line 254, in main
    packages, documents, sources = generate_documents(source_files, opts.cache_dir)
  File "/Users/eric/.virtualenvs/readthedocs/lib/python2.6/site-packages/javasphinx/apidoc.py", line 169, in generate_documents
    this_file_documents = generate_from_source_file(doc_compiler, source_file, cache_dir)
  File "/Users/eric/.virtualenvs/readthedocs/lib/python2.6/site-packages/javasphinx/apidoc.py", line 147, in generate_from_source_file
    if newer == cache_file:
UnboundLocalError: local variable 'cache_file' referenced before assignment

Fails to compile on OSX

...gives ld: library not found for -lrt when installing via pip. Works fine on Ubuntu.

Aware that osx does not have librt - is it actually used by javasphinx?

Unexpected AttributeError exception: 'DocBlock' object has no attribute 'authors'

I get an exception when running javasphinx on the following input (Test.java):

package test; /*\* Test */ public class Test {}

Here's the stack trace:

ERROR:root:Unexpected exception while compiling /home/viz/Downloads/1/javasphinx/in/Test.java Traceback (most recent call last): File "/home/viz/Downloads/1/javasphinx/javasphinx/apidoc.py", line 170, in generate_from_source_file documents = doc_compiler.compile(ast) File "/home/viz/Downloads/1/javasphinx/javasphinx/compiler.py", line 303, in compile document = self.compile_type_document(import_block, package, name, declaration) File "/home/viz/Downloads/1/javasphinx/javasphinx/compiler.py", line 208, in compile_type_document type_dir = self.compile_type(declaration) File "/home/viz/Downloads/1/javasphinx/javasphinx/compiler.py", line 82, in compile_type doc = self.__output_doc(declaration) File "/home/viz/Downloads/1/javasphinx/javasphinx/compiler.py", line 44, in __output_doc if doc.authors: AttributeError: 'DocBlock' object has no attribute 'authors'

Javasphinx is run as follows:

from javasphinx import apidoc apidoc.main()

with only input directory containing a single file (Test.java above) and output directory specified, all other options are set to their defaults.

4 column based index found

System

Mac OS X 10.11.6
Python 2.7.10
Sphinx v1.4.6
javasphinx 0.9.13

Problem

Everything works as expected. However, when generating documentation sphinx reports the following:

WARNING: 4 column based index found. 
It might be a bug of extensions you use: 
[('single', u'done() (Java method)', u'<method_name>', '')]

The documentation is still generated though

exception: No module named javasphinx

this might be an issue for https://github.com/rtfd/readthedocs.org if so, apologies.

A functional (for python) readthedocs django server up and running builds runs javasphinx builds and it shows the following on the "sphinx-build" step:

Running Sphinx v1.5.3
making output directory...

Traceback (most recent call last):
  File "/home/foo/read1/readthedocs.org/user_builds/sample-demo/envs/latest/lib/python2.7/site-packages/sphinx/cmdline.py", line 295, in main
    opts.warningiserror, opts.tags, opts.verbosity, opts.jobs)
  File "/home/foo/read1/readthedocs.org/user_builds/sample-demo/envs/latest/lib/python2.7/site-packages/sphinx/application.py", line 199, in __init__
    self.setup_extension(extension)
  File "/home/foo/read1/readthedocs.org/user_builds/sample-demo/envs/latest/lib/python2.7/site-packages/sphinx/application.py", line 516, in setup_extension
    err)
ExtensionError: Could not import extension javasphinx (exception: No module named javasphinx)

Extension error:
Could not import extension javasphinx (exception: No module named javasphinx)
  • running javasphinx on the command-line works fine

  • python is able to find the javasphinx module when run on the command-line with an import statement in the CLI

  • virtualenv shows the following
    Python 2.7.5

  • pip shows these
    javasphinx (0.9.15)
    readthedocs-sphinx-ext (0.5.4)
    sphinx-autobuild (0.6.0)
    sphinx-rtd-theme (0.2.4)
    sphinxcontrib-httpdomain (1.4.0)

  • java
    openjdk version "1.8.0_121"
    OpenJDK Runtime Environment (build 1.8.0_121-b13)
    OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode)

  • conf.py for the project shows the following
    extensions = ['javasphinx']

Parallel building

javasphinx doesn't let me build my docs in parallel (passing the -j flag to sphinx-build). Is it possible to add support for parallel building? Could be as simple as setting parallel_read_safe to true?

{@inheritDoc} tags are not being processed

When the documentation of a subclass/interface is extended using a {@inheritdoc} tag, such a tag is not processed by javasphinx.

Instead of showing the documentation from the superclass/interface, the {@inheritdoc} tag just shows up in the built documentation.

An example of this issue can be found here.

Add option to treat docblocks as pre-formatted reST

javasphinx-apidoc attempts to mimic the Javadoc tool by converting docblocks from HTML + Javadoc tags into reST. Any pre-formatted reST placed into docblocks will be mangled by this process. An option to javasphinx-apidoc to treat all docblocks as pre-formatted would provide an option for people who would prefer to mark up their docblocks in reST.

Standard java classes do always get linked automatically to external documentation

When building rest files to html with sphinx standard java classes are not linked to explicit documentation in specific cases.

For example let's take a class String:

  1. void myFunc(String param1)
  2. void myFunc(java.lang.String param1)
  3. import java.lang.String;
    ....
    void myFunc(String param1)

In examples 2 and 3 String successfully is linkes to http://docs.oracle.com/javase/6/docs/api/java/lang/String.html. In example 1 it's just a plain text.

Default interface methods cause errors

Hello,

I get this error:

ERROR:root:Syntax error in ../CompositeCheckFactory.java: Expected ';' at final line 24, character 9

The interface looks like this:

public interface CompositeCheckFactory<T extends Tradeable> {

    default List<Rule<T>> getRulesList(final Config config, final Map<String, Rule<T>> baseRules) {
       ...
}

Cache file creation fails on Windows

Please see here.

Could we stop using ':' to replace a file separator so that it runs on Windows? Windows does not allow ':' in a file name. When a absolute path is given in '-c' option, the cache directory path already contains ':' in it (e.g. C:...), so you need to replace any existing colons in the path as well.

How i can specific encoding for javasphinx-apidoc output?

I have a java project, where my java files use the "UTF-8" encoding, 'cause the comments on some classes are writted on spanish using accents.

When i run the command.

javasphinx-apidoc -o docs/java ~/Development/Projects/code/java -f -v

always return the follow error:

Traceback (most recent call last):
    File "/Users/user/Development/Projects/Docs/sphinx/myenv/bin/javasphinx-apidoc", line 11, in <module>sys.exit(main())
    File "/Users/user/Development/Projects/Docs/sphinx/myenv/lib/python2.7/site-packages/javasphinx/apidoc.py", line 317, in main write_documents(documents, sources, opts)
    File "/Users/user/Development/Projects/Docs/sphinx/myenv/lib/python2.7/site-packages/javasphinx/apidoc.py", line 112, in write_documents f.write(document)
    UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in position 1464: ordinal not in range(128)

I wanto to specific the encoding of the files for the apidoc can write this files using utf-8.

is this possible?

i asked this question on SO in this thread

Thanks for your help.

Request: add linkcode-like links to sources

It would be nice to have links to external sources throughout the generated docs. I.e. if my project is hosted on GitHub, it would be nice to have a link to https://github.com/<author>/blob/master/.../.java#Lxxx

I believe these can be retrieved from javalang's position property (if I'm reading the sources correctly).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.