7

I have my Java source code in the standard src/ lib/ test/ directory structure for my project. I want to generate a web view of my source code where I can fire up a browser and see syntax-highlighted, line numbered code. I not only want this but I also want the files to be correctly linked (e.g. clicking on a method/class/interface etc name on the webpage view of the code, it would take me "Eclipse-style" to the relevant page). Is there any piece of software that already does this? I know there is tons of syntax highlight js and css out there so that part is easy and thus I am more interested in the linking part.

pathikrit
  • 32,469
  • 37
  • 142
  • 221
  • "... more interested in the linking part." Highlighting keywords is easy. Getting cross-references right means simulating what the compiler does in resolving what a name refers to. That's a lot harder. – Ira Baxter Jun 22 '11 at 04:19
  • Ira is correct, this could be quite a lot of work. Would producing JavaDocs, with source attached and linked not suffice? Not quite what you described, but maybe close enough? – Crollster Jun 22 '11 at 05:23
  • @Ira, yes, it is a hard question, else I probably would not be asking :) I would imagine if the bin/ directory is available, we can look at the .class files and the .class files have all the info (they have line numbers too I believe) we need but yes it is hard to do and I don't know any tool that does it. – pathikrit Jun 22 '11 at 08:40
  • @Crollster, no it won't suffice - we have an extremely large code base and sometimes it is faster for engineers to just have a simple web view for what's going on than checkout and update millions of lines of code and grep through it or load it in an IDE. – pathikrit Jun 22 '11 at 08:42

3 Answers3

1

See our Java Source Code Browser. Combines Java source code browsing with JavaDoc style cross references. Hyperlinks on identifiers follow Java's scoping rules fully.

Presently operates with Java 1.4, now completing versions for Java 1.5 and up.

EDIT May 2012: Handles Java 1.6 and Java 7

Ira Baxter
  • 93,541
  • 22
  • 172
  • 341
  • Awesome - almost exactly what I was looking for. Throw in line numbers and universal code search OpenGrok style and some better syntax highlighting (http://code.google.com/p/google-code-prettify/) and support Java6 and I would have exactly what I want! – pathikrit Jun 22 '11 at 08:56
  • no I am in Mountain View but I did go to UT-Austin and yes, I would love to play with the beta. My email is on my profile. Thanks! – pathikrit Jun 22 '11 at 16:15
  • @wrick - your profile says you are in Austin. Time to update it :-} – Ira Baxter Jun 23 '11 at 03:41
  • The Browser doesn't do searches; it produces pure HTML. You can see a search engine for large scale multilingual system at www.semanticdesigns.com/Products/SearchEngine – Ira Baxter Jun 23 '11 at 03:50
1

I think your best bet would be Cobertura. Out-of-the-box it will generate nice HTML versions of your source. As a side benefit, it will also generate your code coverage report as well. ;)

Maven JXR is another option as well (if you are using Maven).

Will Iverson
  • 2,009
  • 12
  • 22
  • 1
    OP said, "thus I am more interested in the cross-linking part". Does Coberatura produce correct cross-links? – Ira Baxter Jun 22 '11 at 04:17
  • I just checked the recent version, Cobertura doesn't appear to do cross-links, but Maven JXR does. – Will Iverson Jun 22 '11 at 05:53
  • Maven JXR is indeed very close to what I am looking for (http://maven.apache.org/jxr/xref/org/apache/maven/jxr/JavaCodeTransform.html) but it only does Class name hyperlinks. It would be great if it did even method (and variable?) name hyperlinks too. And no, I don't use Maven - as I said I have a very simple project structure with limited external dependencies (I have only 4 jars in my lib/ - Guava, Apache Commons, Log4J and MySQL) so I have not felt the need to use Ant or Maven – pathikrit Jun 22 '11 at 08:46
0

OpenGrok does much of what you are asking for, also allowing for interesting searches.

alanc
  • 4,102
  • 21
  • 24
joeslice
  • 3,454
  • 1
  • 19
  • 24