adding links in javadoc to source files on google code - java

I work on an open source project that is hosted on google code. I'm using ant to create javadocs and I'd like to have links to the source files. I understand I can use the linksource flag to javadoc to include the source in the resulting html, but this isn't what I really want. What I'd prefer is to provide a link to the source file in google code's svn browser. I suppose I could do a simple filter prior to running javadoc, but it'd be even better if I could figure a way to do this right in javadoc. Ideally, I could have a property in my ant properties file like
base.src.url=http://code.google.com/p/myproject/source/browse/branches/1.2
and the javadoc command would add a line to each class's html file:
see source on google code
Any ideas?

The standard doclet offers no such option, as far as I know. So it looks you either have to
use an alternative doclet,
patch the standard doclet,
preprocess the Java files or
postprocess the produced HTML.
A feature request to include this in the standard doclet might also be a good idea.

Related

What does Javadoc do in Eclipse?

When you start Eclipse up you have a few programs (not sure what to call them) at the bottom like Javadoc, Console, Declaration etc.
I want to know what Javadoc does because I don't really understand how it works.
I have searched online but it does not make much sense to me as I am a beginner.
Javadoc is a documentation tool which defines a standard format for such comments, and which can generate HTML files to view the documentation from a web broswer. You can generate JavaDoc in Eclipse or NetBeans IDE in order to read it via your browser.
Check the official documentation of Oracle: Java SE Overview
As others have written: javadoc is the standard way of putting documentation into your source code (for later processing).
That javadoc view within eclipse simply displays the javadoc of the element that you currently select within the Java editor.
So: just put some javadoc before your class and before some methods and experiment with what that view is showing you.
The JavaDoc is a tool to create a documentation. In combination with the Java annotations and Java Doc-Comments you can create your own documentation for your code.
Java Doc-Comments:
https://en.wikipedia.org/wiki/Javadoc
The Java-Doc Tool in Eclipse can create a good looking documentation like the normal Java utils doc. This -> https://docs.oracle.com/javase/7/docs/api/

Modifying Javadoc

Hi I am trying to generate Javadoc for some of my classes, but I was wondering if there are any way to modify or edit the template to the Javadoc. Also I am not using any IDE, I am using command line to generate the Javadoc
Also is there any way to generate just the className.html and stylesheet.css only?
because it generates all these other files I don't need and it just looks messy.
It will be easier when you use an IDE
You can use Eclipse IDE to generate Java Doc.
You can change templates too.
And you can modify the Java Doc Style too.
How to generate Javadoc HTML in Eclipse?
How do I change the Javadocs template generated in Eclipse?
How to change default javadoc stylesheet?

Diff-Tool that can autoformat source code before comparing?

I've been using WinMerge, Eclipse's compare tool and Tortoise's to see my changes before committing. The problem is that when I edit a file that hasn't been edited by someone else since we last updated our autoformatter-configuration I'll see many, many changes caused by the autoformatter.
Now I have to copy the code from the previous revision, autoformat it in Eclipse and copy it into WinMerge to only see I really made.
Is there a tool that can automatically autoformat both versions of the file I'm comparing?
Any diff tool that allows you to set up an external conversion before the comparison should handle that. External conversions are primarily intended for things like Word/Excel/PDF to Text conversion, but you can do anything you want as long as you can run it from the command line.
For Beyond Compare we already have an optional add-on rule that will use Jalopy to format Java source and another one that use HTML Tidy for HTML files.
WinMerge doesn't look like it supports a Java reformatter out of the box, but their plugins page does describe how you could add one using a dll or Windows Scripting Host scriptlet.

PrettyTime JSP tag

I'm trying to put PrettyTime into JSP as a tag. Found this page - http://www.ke-cai.net/2010/03/formatting-time-with-prettytime-jsp-tag.html - as the only source of the tag. But I've never used Maven, so I can't figure out how to get that prettyTime.tag file along with the source code. Can someone suggest something or should I just go ahead and write a tag myself?
From what I can see in that article, all Maven will be doing is pulling in the java library. You can do this manually, and include it in your standard way (ie, in your "lib").
He seems to be telling you then how to write your own jsp tag (suggesting you call it "prettyTime.tag"), and then how to reference it.
Side note, you may want to consider reading up on and adopting Maven, its quite a powerful build management helper for java web app development.
That's just a blog of someone else. It's available by the manufacturer's site: http://ocpsoft.com/prettytime/
It's however a JSF tag, which means that you have to install and use JSF as well.
Instead of using a server-side component, you can use javascript. See the jQuery timeago plugin

How to generate a PDF from JavaDoc (including overview and package summaries)

I have written extensive JavaDoc documentation on my application, and added lots of useful info at overview.html and package.html files (including links on the former to illustrations in doc-files/). Maven's Javadoc plugin nicely uses the standard javadoc tool to generate the classic JavaDoc frameset, but now I need to generate a PDF with the whole documentation.
AurigaDoclet generates very pretty PDFs, and I was able to make DocFlex work also. However, both ignore my overview.html and package.html files (tried both inside and outside Maven - the PDF will be a once-only thing, since I'd rather have the HTMLs on the long run).
Does anyone know how to make AurigaDoclet recoginze my non-Java files? Or, alternatively, another to generate a decent-looking PDF from either the source code or the JavaDoc-generated HTML?
Nailed it. After trying all the possible tools to generate straight from the source, I returned to HTMLDOC. It is not JavaDoc-aware, but it is so well built that a few tweaks are enough to make it generate a pretty usable PDF.
Here goes a step-by-step description of how I did it:
Download the software on the releases page;
Generate your traditional HTML docs in your preferred way (Ant, Maven, command-line javadoc - your choice);
The GUI is nice, but adding all files manually can be cumbersome, so just create a .book file with Document Type set to "Web Page", add one of the HTML files from your generated javadoc's root folder (e.g., overview-summary.html, anyone will do, it's just for reference on step 5). On the Output tab select the PDF format and set a name for it, and add other options to your heart's content (logos, colors, lots of cool stuff here). Save this project (say, myjavadocpdf.book) and close the GUI
Generate a list of all HTML files in your javadoc. I did it with Cygwin's find command (my DOS/cmd shell days are long over), but you can do anything you want, as long as you get a file list. In my case a find . | grep html$ | sort -r > files.txt did the trick;
For Windows users, dir /s/b *.html > files.txt should do the same (but keep in mind you may have to replace \s with /s if they appear like so on the next step).
Open the .book file generated on step 3 in your favorite pure text editor (as a programmer you should have strong opinions on that, so will keep my opinions to myself - NOT ;-) ) and append the list generated on step 4 to this .book file (it keeps the list of files at the end, making life really easy). Don't forget to fix the relative paths, if needed with a global search/replace (that's why you needed at least one file added on step 3 - to see which file path pattern htmldoc expects);
Now you should sort the files in a convenient order. I put my overview first, then package descriptions and each class, then the full index, and everything else at the end. Remember that any file you delete will become an external (hence broken) link, so choose wisely;
Save your .book file and re-open it on HTMLDOC. Voila: all files added and sorted. Click on generate. That's it!
You may want to fiddle with images (hint: use HTML width/height, not style/css). In the end, the resulting file is surprisingly good: nice looking and fully navigable for internal and external links. Impressive when you consider that the tool is not Java(Doc) aware at all...
EDIT: software is now free from original author; updated links, thank you #mohammed
According to the Sun JavaDoc FAQ, there's a couple of options -- mostly free, with one or two commercial offerings as well. Check it out at http://java.sun.com/j2se/javadoc/faq/index.html#print.
AurigaDoclet fails to process package.html.
For a fix see my comment at https://sourceforge.net/projects/aurigadoclet/forums/forum/339169/topic/1572199/index/page/1
If this question was bumped anyways, I can use this to link my ltxdoclet project.
This creates from the source (by being a JavaDoc plugin) documentation in LaTeX format, which you then can pass through PdfLaTeX to produce a PDF.
Optionally it also can include pretty-printed source code.

Categories

Resources