This discussion is archived
5 Replies Latest reply: Jan 1, 2009 7:57 AM by 843810 RSS

Javadoc like tool to get referencing and syntax hilighted HTML from source

843810 Newbie
Currently Being Moderated
There are several tools out there which are called java2html. But of the 5 I found links to, 3 where no longer available, one, the gnu one, does not compile on an up-to-date ubuntu and is written in C (strange), and the one that comes with ubuntu does highlighting only.

Nice would be functionality like javadoc has, i.e.
- active links from uses to declarations (like CTRL-click in eclipse)
- index with all occurences, separately marked for definition and use,
- of course syntax highlighting.

To enable this, it would get a whole package or packages to process and would generate the output html files in a different directory (java2html on ubuntu make a/b/c/Bla.java.html from a/b/c.Bla.java :-(

Does anyone know a tool like this?

Harald.
  • 1. Re: Javadoc like tool to get referencing and syntax hilighted HTML from source
    843810 Newbie
    Currently Being Moderated
    Well. If you are a student, you may develop that stuff by your own.
    Then place it at somewhere like sourceforge.net
    A few guys like you will find it and perhaps use it.
    But you will never know... forget to hear anything from them, not even thanks!
    (Just put yourself at their place -- would you write anything to the author?)
    Be proud that someone is probably using it!
    That's probably all benefits you are going to expect from that kind of endeavor.
    Forget about making any money from this!

    Well. By the time you will find a job where they pay you for the stuff you do.
    You will give up your pet project and eventually forget about it.
    Meanwhile, at the hosting site (e.g. at that very 'sourceforge.net'),
    they will reorganize something, as they regularly do,
    move something to somewhere else, do something wrong and the link to your project will get lost...

    That's roughly how the first 5 those tools appeared.
    You may add the sixth!

    BTW, Javadoc itself won't be much helpful for that task because it gives no access
    to the Java source code (particularly in a parsed form). You may develop a custom doclet
    (it must be not less powerful than the standard one, to make any sense of it).
    But in addition to the doclet, you will need to find by yourself the Java source of a particular class, parse it and generate an output by it with all those highlights and links you want.
    This is not so little project... and given nobody will ever pay nobody is going to do it.
    But you may try!
    ;=)
  • 2. Re: Javadoc like tool to get referencing and syntax hilighted HTML from sou
    843810 Newbie
    Currently Being Moderated
    You could modify the -linksource code:
    http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/javadoc.html#linksource
  • 3. Re: Javadoc like tool to get referencing and syntax hilighted HTML from sou
    843810 Newbie
    Currently Being Moderated
    Wow, learn something new everyday. I did not know about the -linksource option. Should I find the time and develop something myself, it should certainly integrate with it.

    Harald.
  • 4. Re: Javadoc like tool to get referencing and syntax hilighted HTML from source
    843810 Newbie
    Currently Being Moderated
    No, I am not a student. Yes, I would have all the abilities to get this going, except enough time. Yes, I know that open source tools get rusty due to effects you described, I have experienced this myself.

    I wonder if reflection could get one around completely and correctly parsing the source again. Or is it rather BCEL to be used to get hold of line number information. Or is there an open interface to the compiler anywhere?

    Harald.
  • 5. Re: Javadoc like tool to get referencing and syntax hilighted HTML from source
    843810 Newbie
    Currently Being Moderated
    I wonder if reflection could get one around completely and correctly parsing the source again.
    No. Java reflection API (java.lang.reflect.* package) provides some basic info about the Java classes being executed. It has no connection with Java source nor even with binary representation of Java classes.

    BCEL is closer to the subject, but still has nothing to do with the source code. If you needed to process the already compiled Java binary classes (e.g. to develop some code obfuscator or trasformer/optimizer) then it would be useful.

    But what you need is a Java parser -- some piece of software that "reads" a human-written Java code and produces by it some tree of objects representing all the Java program things like classes, methods, fields, variables, statements, operators and so on. That object representation will allow you to connect the particular positions of the Java source with the things provided, for instance, by the Doclet API. Then, you will be able to highlight the Java source code and generate hyperlinks from it to all other parts of the documentation.
    Or is there an open interface to the compiler anywhere?
    I think, there must be such libraries, including open source. For instance, a few minute search in Google gave me a couple of links:

    http://code.google.com/p/javaparser/
    https://javacc.dev.java.net/

    There must be more...

    But note. Generally, parsing of an object programming language like Java is not a trivial task. First, I would recommend to read some theory about this (that is how compilers work), simply because all such libraries will likely use some conventional notions and terminology of that field (like "context-free grammars", "LR or LL parser" and so on).