Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

JavaDoc for string prefence fields with empty default value seems incomplete #1877

Description

@ironjan

Issue

The javadoc for @SharedPrefs is generated in SharedPrefHolder like so:

if (defaultValueStr != null) {
    fieldMethod.javadoc().append("<p><b>Defaults to</b>: " + defaultValueStr + "</p>\n");
}

The following example shows what javadocs are generated. The empty default strings lead to a javadoc that seems incomplete when viewed with Android Studio.

@SharedPref
public interface PreferencesInterface {
    // also works with @DefaultString("")
    // will generate "<p><b>Defaults to</b>: </p>"
   String stringField();

   // will generate "<p><b>Defaults to</b>: not empty</p>"
   @DefaultString("not empty")
   String anotherStringField();
}

bildschirmfoto zu 2016-10-16_13-41-52

Suggestions

One possibility would be to include back-ticks in the generated javadoc. This seems to me like a clean solution; I have seen this in ruby docs but not yet in the "java world".

<p><b>Defaults to</b>: `" + defaultValueStr + "`</p>\n

This would generate javadocs like the following:

for empty strings:
  <p><b>Defaults to</b>: ``</p>
for @DefaultString("non-empty")
  <p><b>Defaults to</b>: `non-empty`</p>
for an int field as non-String example
  <p><b>Defaults to</b>: `0`</p>

Another possibility would be to handle strings so that docs like <p><b>Defaults to</b>: ""</p> or <p><b>Defaults to</b>: "not empty"</p> are generated.

Activity

  1. ironjan commented on Oct 16, 2016

    @ironjan
    Author

    Pull Request submitted as #1878. If the back-tick solution is not as clean as I thought, feel free to close the PR and let me know the preferred solution.

  2. dodgex commented on Oct 29, 2016

    @dodgex
    Member

    Fixed in #1878

  3. added this to the 4.2 milestone on Oct 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions