Editing Cs-doclet

Jump to navigation Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 3: Line 3:
== Abstract ==
== Abstract ==


Cs-doclet is a [http://docs.oracle.com/javase/8/docs/technotes/guides/javadoc/ JAVADOC doclet] that generates the metadata files for [http://checkstyle.sourceforge.net/ CheckStyle] and [http://eclipse-cs.sourceforge.net/ eclipse-cs] from annotations and [http://docs.oracle.com/javase/8/docs/technotes/tools/windows/javadoc.html#CHDJGIJB doc tags] in the source code of your checks and filters.
Cs-doclet is a [http://docs.oracle.com/javase/8/docs/technotes/guides/javadoc/ JAVADOC doclet] that generates the metadata files for [http://checkstyle.sourceforge.net/ CheckStyle] and [http://eclipse-cs.sourceforge.net/ eclipse-cs] from annotations and 'doc tags' in the source code of your checks and filters.
 
This doclet is useful only for authors of CheckStyle extensions, like [[Cs-contrib.unkrig.de|cs-contrib]].


== Intended audience ==
== Intended audience ==
Line 118: Line 116:
The generated "src/com/pany/cs/checks/messages.properties" file looks like this:
The generated "src/com/pany/cs/checks/messages.properties" file looks like this:


  # This file was generated by the CS doclet; see http://cs-doclet.unkrig.de/
  # This file was generated by the CS doclet; see http://cs-contrib.unkrig.de
   
   
  # Custom check messages, in alphabetical order.
  # Custom check messages, in alphabetical order.
Line 231: Line 229:


'''File "src/com/pany/cs/checks/checkstyle-metadata.properties":'''
'''File "src/com/pany/cs/checks/checkstyle-metadata.properties":'''
  # This file was generated by the CS doclet; see http://cs-doclet.unkrig.de/
  # This file was generated by the CS doclet; see http://cs-contrib.unkrig.de.
   
   
  # Rule groups:
  # Rule groups:
Line 252: Line 250:
  <checkstyle-metadata>
  <checkstyle-metadata>
   
   
     &lt;!-- This file was generated by the CS doclet; see http://cs-doclet.unkrig.de/ -->
     &lt;!-- This file was generated by the CS doclet; see http://cs-contrib.unkrig.de -->
   
   
     &lt;!-- ColorCheck -->
     &lt;!-- ColorCheck -->
Line 277: Line 275:
  </checkstyle-metadata>
  </checkstyle-metadata>


== Javadoc-like documentation ==
== MediaWiki markup documentation ==


Typically, you will also want to publish human-readable documentation for your checks and filters, which is more or less identical with the text in the eclipse-cs metadata files. This is also possible with the "-d" command line option:
Typically, you will also want to publish human-readable documentation for your checks and filters, which is more or less identical with the text in the eclipse-cs metadata files. This is also possible with the "-mediawiki-dir" command line option:


  $ javadoc \
  $ javadoc \
  > -doclet de.unkrig.doclet.cs.CsDoclet \
  > -doclet de.unkrig.doclet.cs.CsDoclet \
  > -docletpath "path/to/cs-doclet.jar;bin;path/to/checkstyle-6.1-all.jar;path/to/net.sf.eclipsecs.core-6.1.jar" \
  > -docletpath "path/to/cs-doclet.jar;bin;path/to/checkstyle-6.1-all.jar;path/to/net.sf.eclipsecs.core-6.1.jar" \
  > -d ./csdoc \
  > -checkstyle-metadata.properties-dir src \
> -checkstyle-metadata.xml-dir src \
> -messages.properties-dir src \
> <span style="color:red">-mediawiki-dir mediawiki</span> \
  > -sourcepath src \
  > -sourcepath src \
  > -classpath ../net.sf.checkstyle-6.1/checkstyle-6.1/checkstyle-6.1-all.jar \
  > -classpath ../net.sf.checkstyle-6.1/checkstyle-6.1/checkstyle-6.1-all.jar \
Line 292: Line 293:
  $
  $


This will generate a Javadoc-like HTML documentation for all checks and filters that are declared in the given Java packages.
This will generate:
 
'''File "mediawiki/com.pany ColorCheck.mw":'''
<!-- This file was generated by the CS doclet; see http://cs-contrib.unkrig.de -->
<span style="color:red">A completely useless check which merely prints a (localizable) message each time it encounters an annotation.</span>
== Properties ==
Default values appear &lt;u>underlined&lt;/u>.
&lt;dl>
&lt;dt><span style="color:red">color</span> = "&lt;i><span style="color:red">String</span>&lt;/i>" (optional; default value is "<span style="color:red">Yellow</span>")
&lt;dd><span style="color:red">A completely useless check parameter.</span>
&lt;/dl>
 
Upload this text to a MediaWiki repository, and you'll see:
 
[[File:screenshot_mediawiki.jpg]]


And you're done!
And you're done!
Line 299: Line 317:


Before, you had to write one Java file and four more or less redundant metadata files per check; now you merely have to throw in a few annotations and doc comments and generate all four metadata files from the source code
Before, you had to write one Java file and four more or less redundant metadata files per check; now you merely have to throw in a few annotations and doc comments and generate all four metadata files from the source code
== Source code ==
The source code for the plug-in is here:
    https://github.com/aunkrig/doclet-cs
    https://github.com/aunkrig/doclet-cs-annotation
Please note that all contributions to unkrig.de may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see Unkrig.de:Copyrights for details). Do not submit copyrighted work without permission!
Cancel Editing help (opens in new window)