Closed lucasstarsz closed 3 years ago
We're also going to want to set a standard for how docs should be written for each javadoc segment. The format will be present below.
This is where all documentation of the parts of Slope-ECS will have their documentation style defined.
*
) along the side, one space in front of the forward-slash (slash that looks like this: /
) that starts the Javadoc segment.<p>
elements, as this causes compile errors in the Java 15 Javadoc. This is not the default in IntelliJ -- change it by going to File → Settings → Editor → Code Style → Java → JavaDoc
. Under Other
, remove the checkmark for Generate "<p>" on empty lines
. Then, add the checkmark to Keep empty lines
.<h2>Section Name</h2>
<h4>Section Name</h4>
/**
* one-liner.
*
* <h2>Section Name</h2>
* Lorem Ipsum, which I'm too lazy to grab from the internet and bother formatting. This is a sentence that will be
* hard-wrapped at 120 characters.
*
* <h2>Another Section Name</h2>
* More lorem ipsum, perhaps.
*/
public class Example {}
A single sentence describing the method, class (or variant), or variable's purpose in the code.
The section immediately declared after the one-liner.
Declared with the @author
Javadoc tag, the author or authors of an element should be specified.
While you are not required, it is strongly recommended you put your real name instead of your display name. (For example, I put Andrew Dey
instead of lucasstarsz
.) I understand that user anonymity is always a concern, but this is an open-source library -- by putting your name on something, you should be able to take credit for it in the business world.
Declared with the @since
Javadoc tag, the original version in which an element was implemented should be specified.
0.1
to 0.2
.0.1.1
to 0.1.2
.Declared with the @version
Javadoc tag, the current version should be specified only if the element was modified since the original version. The current version does not need to be specified for every release increment if the element did not change during that increment.
@version
tag updated, then the reasoning behind the update should be specified in the about section of its documentation. The reasoning should come straight from the git commit message from when that method update happened. If the reasoning is more than a few sentences, then a brief statement about the change complemented by a link to the commit where the change was implemented will suffice.Coming after the element's about section, this section is to provide a usable, understandable sample code to demonstrate what an element does and its effect on other things outside of its state.
{@code }
Javadoc tag, which is then wrapped in a <pre>
HTML tag. The result is shown in the example.{@return }
tag for getter/setter methods should be maintained in a single line of Javadoc.This class would be part of a mock library currently in version 0.2.4
:
/**
* An example class depicting the way documentation should be written in Slope-ECS.
*
* <h2>About</h2>
* Rather than expect people to read my mind and understand exactly what I want in the Slope-ECS Javadoc, I chose to
* write this format guide instead. Hopefully, it will give you all an understanding of what I expect for the Javadocs
* in this library.
*
* @author Andrew Dey
* @since 0.1
*/
public class DocumentationExample {
/** An integer to aid me in giving an example Javadoc. */
private int foo;
/**
* The default constructor for the {@code DocumentationExample} class.
*
* <h4>About</h4>
* Oh yes, I'm sure you'd get tired of writing the section name every time. Well, there isn't really a way to avoid
* needing to write in this format, unless at some point we make a custom doclet which adds these things as
* custom annotations. That would be cool if we could come up with that, just throwing it out there.
*
* This constructor only serves to initialize the internal values of the class.
*
* @author Andrew Dey
* @since 0.1
*/
public DocumentationExample() {
foo = 1;
}
/**
* Prints the value of {@link #foo}, then adds the parameter to it.
*
* <h4>About</h4>
* This method purely serves the purpose of printing and modifying the {@link #foo} variable. The original value
* gets printed out first; {@code foo} then gets the {@code fooModifier} parameter added to it.
*
* <h4>Example Usages</h4>
* <pre>{@code
* DocumentationExample example = new DocumentationExample();
* System.out.println("Original value of foo: " + example.getFoo());
* example.printFoo(5);
* System.out.println("Foo, after it was modified: " + example.getFoo());
*
* // This code will print the following:
* // Original value of foo: 1
* // 1
* // Foo, after it was modified: 6
* }</pre>
*
* @param fooModifier The value to add to {@link #foo}.
*
* @author Andrew Dey
* @since 0.2
*/
public void printFoo(int fooModifier) {
System.out.println(foo);
foo += fooModifier;
}
/** {@return the value of {@link #foo}} */
public int getFoo() {
return foo;
}
}
If any questions persist beyond what this guide covers, or if you think something should be added or specified, please open an issue and let your voice be heard.
As suggested by an anonymous person, we should consider allowing display names in the @author section instead of just business names. Until further notice, that will be allowed so long as the name is not inappropriate.
Due to HTML compile issues, we will no longer have empty lines use the <p>
tag.
Thanks to more HTML compile errors, and some interesting CSS, class headings will now use <h2>
for sections; all other elements will use <h4>
.
All the formatting errors have been resolved. Awaiting release.
In the Java 16 specification, the new recommended way to avoid duplication for getters/setters is to use the inline {@return }
tag, which avoids repeating yourself.
For the foreseeable future, this will be the way getter/setter methods are documented.
Now that the wiki has been added, we need to have documentation that matches its clarity.