Is there a way to produce Javadoc for a subset of public methods? For example by annotating public methods as “not part of the public API”

后端 未结 2 1872
孤独总比滥情好
孤独总比滥情好 2021-01-12 10:22

I know how to produce Javadoc for a subset of classes/interfaces/packages. But is there a way to produce Javadoc for only a subset of public methods?

What I would pr

2条回答
  •  鱼传尺愫
    2021-01-12 10:56

    If you're using the javadoccommand line tool, you can exclude public methods by marking them as Deprecated and using the -nodeprecated option. But if you want something more sophisticated, you'll have to implement it yourself.

    A rough idea on how to do it:

    1. Create custom annotations @API1, @API2, etc.
    2. Classify your methods with those annotations (i.e. mark them)
    3. Write a custom Ant task which reads a configuration parameter (from a file, for example) that tells which API you want to generate the Javadoc for.
    4. Still in the Ant task, Loop through the annotated methods and replace all API annotations which are NOT the selected API with the Deprecated annotation. This will exclude them from Javadoc.

    IMHO, this is a lot of hassle. Like they said in the comments, if you have a class with multiple interfaces (for different user profiles, I guess?), consider writing separate interfaces.

提交回复
热议问题