Whenever I type in "Printing" and hit CTRL Q in intelliJ I can only see the "Summary" and I cant see "Bob" . . . what am I doing wrong?
package printing;
/**
* #author Bob
* <b>Summary</b>
*/
public class Printer {
//stuff
}
***Note: I am just learning how to use the "javadoc" so I would appreciate an explanation.
EDIT: I cant even see "Summary" unless I take out the "#author"
Sounds like a problem/feature of IntelliJ. Eclipse shows whole javadoc including #author. Other possible problem is a presence of <b>Summary</b> right after #author.
So, try to remove the summary and see what happens. Try also to really generate javadoc, e.g. run javadoc utility from command line and see what happens. I am sure that in this case Bob will appear. Good luck.
I can reproduce this behavior and have raised an issue to track this : http://youtrack.jetbrains.com/issue/IDEA-114499
Here is the bit of code I used:
package printing;
/**
* #author Simba
* #version 1
* #see java.util.Arrays
* #since 1
*/
public class Printer {
}
And the resulting documentation:
However, if you try to generate the javadoc via Tools -> Generate JavaDoc with the following settings :
then, the resulting generated javadoc does show the author tag:
therefore proving that the javadoc itself is sound and that it is IntelliJ that does not display it.
When javadoc is used from the console, you can add the -author and -version options to the call like this (-d sets the output directory):
javadoc src/main/java/com/*.java -d src/docs/javadocs/ -author -version
Author and version are displayed using those settings.
The javadoc help (by just typing javadoc) shows the following - as AlexR already mentioned - (shortened):
...
Provided by Standard doclet:
-d <directory> Destination directory for output files
-use Create class and package usage pages
-version Include #version paragraphs
-author Include #author paragraphs
...
If you do in command line you can use this:
javadoc -d javadoc -author -version YourClass.java
Change the name of the .java to your class name.
Is necessary add -author if you want to show the author tag and the same with the version -version
Remember, the -d argument is used to define the folder and depend of your actual path, so if you are in C:\Users\joselito your javadoc folder has to be in C:\Users\joselito\javadoc
When you click on generate Javadoc then you will find some options .
Go to below the output directory .
Tick the author option .
// this is for intellij Idea.
Related
Background story: I want vim to generate a public class declaration when editing new java files, so I wrote the following augroup:
augroup generate_public_class_declaration_upon_creation
au!
autocmd BufNewFile *.java execute "normal! ipublic class " . expand('%:t:r') . "\<CR>{}\<Left>\<CR>\<CR>\<Up>\<Tab>" | startinsert
augroup END
Which works fine when put in .vimrc, but no longer functions after being transferred to ftplugin/java.vim. I tried some other events e.g. BufWritePre, BufWinEnter inside java.vim and nothing goes wrong. What's happening?
By the time that snippet is executed from your ftplugin it is already too late for catching the BufNewFile event.
You can either leave it in your vimrc, where it is known to work, or modify it so that it can be executed from your ftplugin.
Here is a quick and dirty solution:
" in after/ftplugin/java.vim
if !(bufname()->filereadable())
execute "normal! ipublic class " . expand('%:t:r') . "\<CR>{}\<Left>\<CR>\<CR>\<Up>\<Tab>" | startinsert!
endif
where we check if there is a file for the current buffer before inserting our skeleton.
Basically, when you do :e foo.java or $ vim foo.java, a buffer is created with the name foo.java, which is supposed to be the name of the associated file and can be retrieved with :help bufname(). If a file with that name doesn't exist, we check with :help filereadable(), we can insert the skeleton.
Note the ! after startinsert: without it the insertion would happen before the <Tab>. See :help :startinsert.
i'm trying to generate some javadoc via ant for a small testproject but i don't really understand all of its behaviour. It seems that a lot of methods in my main class are left out and i don't really udnerstand why.
Here is an example:
/**
* Diese Methode deligiert die Ausfuehrung der zustandsabhaengigen Aktion an die entsprechende Methode
* des Zustandsobjektes weiter, welches gerade in der Objektvariable zustand gespeichert ist.
* #see SetMinutes
* #see SetHours
* #see DisplayTime
*/
void inc(){
zustand = zustand.inc(this);
}
This one isn't shown. My ant target looks like this:
<target name="doc" depends="generateJar">
<javadoc destdir="${doc.dir}">
<fileset dir="."/>
</javadoc>
</target>
The only methods being shown are the main method (which is documented) and a run() method (empty). What makes me wonder as well is that my documentation for methods in the other classes of the project are generated properly and i can't see the difference.
(I have problems with generating a fields summary too but that's probably stuff for another question, isn't it?)
Any help would be appreciated.
The default javadoc command line option is -protected, which generates only public and protected methods.
To get package-private methods (as inc() is) you must specify -package or -private.
Oracle Documentation: http://docs.oracle.com/javase/8/docs/technotes/tools/windows/javadoc.html#CHDCIFFD
EDITED: to fit Stefan Bodewigs comment.
With the hint of Jim Garrison i was able to figure out the solution which is as follows (i will also sum up what was already said to have everything in one post):
default command line option of javadoc is -protected which won't generate javadoc for private and package private fields and methods
if one wishes to automate this via ant we can use
package="true" (or private="true" if one wishes to include those fields and methods, too)
Example:
<target name="doc" depends="generateJar"> <!--default option für javadoc ist -protected (siehe Web) daher fliegen im default package private methoden raus aus der doc-->
<javadoc destdir="${doc.dir}" package="true">
<fileset dir="."/>
</javadoc>
</target>
Change dirctory to the folder which contain your javacode.
Compile the code.
Then run the following Command.
javadoc -private -splitindex <(compiledclassfilename)>.java
When I use IntelliJ's Inspect Code, the IDE shows the following warning message:
Name
Test.java
Location
package test.exercisefile Test.java
Problem synopsis
Checkstyle: #author=John.Doe (at line 32)
My actual source comment is:
/**
* #author John.Doe
**/
public class Test {...
I have no idea what #author=John.Doe means.
I appreciate any advice about how to fix this warning. Thanks!
So I am learning to make a general template for java. So in Netbeans I went to the Tools menu and opened the Templates Manager and Opened the Java Class Template. This is what I did:
<#if package?? && package != "">
package ${package};
</#if>
/**
*
* Author: ${user}
* Created : ${time} ${date}
* Last Modified : ${lastUpdated}
*/
public class ${name} {
}
And the output is this:
package Maths;
/**
*
* Author: Emanuel Parkman
* Created : 3:40:29 AM May 22, 2014
* Last Modified : Expression lastUpdated is undefined on line 9, column 22 in Templates/Classes/Class.java.
*/
public class NewClass {
}
But when I look at the Freemarker Website : http://freemarker.org/docs/ref_builtins_date.html#ref_builtin_date_datetype
${lastUpdated}
Is used as one of the built-ins... I just want my comments to show when the java file was last saved. Is that possible? and if so, how?
You misunderstand the manual there. lastUpdated is not a built-in variable in FreeMarker. All the variables that you are using, like name, package, time, are provided by NetBeans. After all, FreeMarker is not specialized on generating source code (in fact, it's much more often used for generating Web pages). So check what variables are available in the NetBean documentation. Or, maybe try to list the available variables, like described here: does freemarker support show all variable in data-model?
We'd like to have the version of the java source code, in our case the svn $Id$ string, embedded in the generated class file.
We'd like to be able to determine this information from a static inspection of the class file, preferably by running the strings or what command.
A naive attempt to declare a private final static String variable set to this value inside each class didn't result in a legible string embedded in the class file.
You said ... preferably by running the strings or what command ...
Let's assume you have something like this in your code:
private static final String SVN_ID =
"$Id: SvnIdDemo.java 1081 2008-09-30 19:03:23Z john $";
The following Perl one-liner ...
$ perl -nwe 'print "$1\n" if /.*(\$Id:[^\$]+\$).*/' SvnIdDemo.class
... prints the SVN ID string to STDOUT.
$Id: SvnIdDemo.java 1081 2008-09-30 19:03:23Z john $
You could add a method to the bottom of each class with a predefined name. Say you used:
public String extractChaimGeretzVersionNumber() {
return "$Id$";
}
Then you find the version with a program that loads the class and, via reflection, calls the magic method and retrieves the version.
You would either have to have code that inserted the method to the .java files before building the .class and .jar files OR you could have a build step that checked that the magic method was already in every one of them. Fail the build if not found.