java-docs

作者: github

Javadoc 最佳實踐,用於記錄 Java 類型、方法及成員。公有和受保護成員需要 Javadoc 註解;套件私有和私有成員也建議添加,特別是複雜程式碼。使用標準標籤:@param 用於參數、@return 用於回傳值、@throws 用於例外、@see 用於交叉參考、@since 用於版本追蹤。第一句作為摘要描述,應以句號結尾;參數描述以小寫開頭,不加句號。使用...

npx skills add https://github.com/github/awesome-copilot --skill java-docs

Java Documentation (Javadoc) Best Practices

  • Public and protected members should be documented with Javadoc comments.
  • It is encouraged to document package-private and private members as well, especially if they are complex or not self-explanatory.
  • The first sentence of the Javadoc comment is the summary description. It should be a concise overview of what the method does and end with a period.
  • Use @param for method parameters. The description starts with a lowercase letter and does not end with a period.
  • Use @return for method return values.
  • Use @throws or @exception to document exceptions thrown by methods.
  • Use @see for references to other types or members.
  • Use {@inheritDoc} to inherit documentation from base classes or interfaces.
    • Unless there is major behavior change, in which case you should document the differences.
  • Use @param <T> for type parameters in generic types or methods.
  • Use {@code} for inline code snippets.
  • Use <pre>{@code ... }</pre> for code blocks.
  • Use @since to indicate when the feature was introduced (e.g., version number).
  • Use @version to specify the version of the member.
  • Use @author to specify the author of the code.
  • Use @deprecated to mark a member as deprecated and provide an alternative.