X Tutup
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

@ironjan

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.

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

      X Tutup