lucasstarsz / Slope-ECS

An Entity Component System written in Java, based on Austin Morlan's C++ ECS.
MIT License
14 stars 1 forks source link

More Documentation #12

Closed lucasstarsz closed 3 years ago

lucasstarsz commented 3 years ago

Now that the wiki has been added, we need to have documentation that matches its clarity.

lucasstarsz commented 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.

lucasstarsz commented 3 years ago

Slope-ECS Javadoc Format

This is where all documentation of the parts of Slope-ECS will have their documentation style defined.

Style of Javadocs

Javadoc Rules

General Javadocs

One-Line Description

A single sentence describing the method, class (or variant), or variable's purpose in the code.

General Javadoc, excluding variables

About Section

The section immediately declared after the one-liner.

Author

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.

Origin Version

Declared with the @since Javadoc tag, the original version in which an element was implemented should be specified.

Current Version (ONLY IF MODIFIED SINCE ORIGINAL)

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.

Methods

Example Usages

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.

Getter/Setter methods

Example 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.

lucasstarsz commented 3 years ago

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.

lucasstarsz commented 3 years ago

Due to HTML compile issues, we will no longer have empty lines use the <p> tag.

lucasstarsz commented 3 years ago

Thanks to more HTML compile errors, and some interesting CSS, class headings will now use <h2> for sections; all other elements will use <h4>.

lucasstarsz commented 3 years ago

All the formatting errors have been resolved. Awaiting release.

lucasstarsz commented 3 years ago

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.