Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull Pojo DTO documentation, report layout and link handling #26

Merged
merged 48 commits into from
Jul 24, 2012
Merged

Pull Pojo DTO documentation, report layout and link handling #26

merged 48 commits into from
Jul 24, 2012

Conversation

timw
Copy link

@timw timw commented Jan 23, 2012

We've been making some local improvements to the JAX-RS doclet to handle our setup (POJO style Jackson serialization) and improve the produced reports.

Notably:

  • Optionally generate documentation pages for DTOs referenced in resource methods after the resource methods are resolved
  • @link tags are now supported in documentation on resource methods, linking to resource classes or resource methods
  • The resource layout has been modified to make it more visually consistent/clear (this may not be to your liking, as we use a custom CSS as well)

I've done one pull request so you can have a look at the improvements to date, but let me know if you want it chunked up a bit finer.

timw added 21 commits January 23, 2012 10:52
…et pages so we have top and bottom CSS classes applied to all menus.

Styling of the bottom menu can now be distinct from the top menu (e.g. to add more margin-top on the index pages).
…n POJO style DTO serialization is being used:

-enablepojojson : a flag that activates DTO documenation
-matchingpojonamesonly : a regex for types to generate DTO documentation for
…etWriter as a superclass, removing redundant printOtherMenuItems methods.
…S resource methods when DTO serialization is done using a Pojo style (i.e. Jackson POJO -> JSON serialization).

Data object types that are not external, but are resolvable in the current Javadoc source path (which can be extended using standard javadoc include mechanisms) are documented at a field level, and linked from the method details.

A new top level Data objects page is generated and added to the menu, listing all data objects resolved during resource documentation.
…space at bottom of pre block in documenation.
…ame that show the fully qualified type name.
- Make the resource method sections distinct and with a consistent structure
- Make the resource list and method list tables distinct and with a similar structure to the method details section
- Remove the examples table if only one example is shown, to simplify styling
…tion only (without a DocletWriter), for use where the DocletWriter context may not be available.
…d resource classes.

{@link ResourceClass/ResourceLocatorClass} is now supported, as is {@link ResourceClass#resourceMethod()}.

Resource method links are labelled with the HTTP method(s) of the resource, while resource class links link directly to the resource path.

ResourceClass/Locator type hierarchies are followed, so resource locator extension/interface implementation is allowed.
…be documented based on a regular expression.

This is useful when you are including DTOs from a shared source path that also includes resources (i.e. you're developing two distinct web services that share DTOs).
@FroMage
Copy link
Owner

FroMage commented Jan 27, 2012

Hey this looks great, I want to merge that in, as soon as I take a look at the resulting HTML (the code looks good).

But unfortunately when I run the tests I get this exception:

$ mvn -pl doclets integration-test
[...]

Exit code: 1 - javadoc: error - In doclet class com.lunatech.doclets.jax.jaxrs.JAXRSDoclet,  method start has thrown an exception java.lang.reflect.InvocationTargetException
java.lang.NullPointerException
    at com.lunatech.doclets.jax.jaxrs.writers.MethodWriter.printOutputGenericType(MethodWriter.java:219)
    at com.lunatech.doclets.jax.jaxrs.writers.MethodWriter.printOutputType(MethodWriter.java:213)
    at com.lunatech.doclets.jax.jaxrs.writers.MethodWriter.printOutput(MethodWriter.java:181)
    at com.lunatech.doclets.jax.jaxrs.writers.MethodWriter.printMethod(MethodWriter.java:95)
    at com.lunatech.doclets.jax.jaxrs.writers.MethodWriter.print(MethodWriter.java:60)
    at com.lunatech.doclets.jax.jaxrs.writers.ResourceWriter.printMethodDetails(ResourceWriter.java:119)
    at com.lunatech.doclets.jax.jaxrs.writers.ResourceWriter.write(ResourceWriter.java:63)
    at com.lunatech.doclets.jax.jaxrs.model.Resource.write(Resource.java:160)
    at com.lunatech.doclets.jax.jaxrs.model.Resource.write(Resource.java:163)
    at com.lunatech.doclets.jax.jaxrs.JAXRSDoclet.start(JAXRSDoclet.java:111)
    at com.lunatech.doclets.jax.jaxrs.JAXRSDoclet.start(JAXRSDoclet.java:86)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.sun.tools.javadoc.DocletInvoker.invoke(DocletInvoker.java:269)
    at com.sun.tools.javadoc.DocletInvoker.start(DocletInvoker.java:143)
    at com.sun.tools.javadoc.Start.parseAndExecute(Start.java:340)
    at com.sun.tools.javadoc.Start.begin(Start.java:128)
    at com.sun.tools.javadoc.Main.execute(Main.java:41)
    at com.sun.tools.javadoc.Main.main(Main.java:31)

timw added 8 commits January 31, 2012 14:27
…a JAXBType) prior to documenting an input/output.
…arameters, not the enclosing type, to allow interface methods to be matched to implementation class methods.
- utilising the full local type name for the file, not just the simple type name)
- using the simple type name for the display text
… (class extension only) DTOs.

Superclass is now reported in index and data object page.
Subclasses are listed in data object page.
@FroMage
Copy link
Owner

FroMage commented Mar 14, 2012

@timw: I really want to merge your stuff, did you take a look at my previous questions?

Also I have a question regarding @link support: I don't see where you did anything to support it, I only see a method related to SeeTag, but that's not the same, right? I'm asking because another user is having issues with @link at #37.

@timw
Copy link
Author

timw commented Mar 14, 2012

Hi

I'm trying to get some time to work on this in the next week. I'll see if I can tidy up as requested and update the pull request.
I've also got a bunch of local fixes pending that I'll do at the same time.

The @link support is all in JAXRSHtmlDocletWriter.seeTagToString(SeeTag).

cheers
tim

----- Original Message -----

From: "Stéphane Épardaud" reply@reply.github.com
To: "Tim Whittington" Tim.Whittington@orionhealth.com
Sent: Wednesday, 14 March, 2012 11:03:49 PM
Subject: Re: [jax-doclets] Pull Pojo DTO documentation, report layout and link handling (#26)

@timw: I really want to merge your stuff, did you take a look at my previous questions?

Also I have a question regarding @link support: I don't see where you did anything to support it, I only see a method related to SeeTag, but that's not the same, right? I'm asking because another user is having issues with @link at #37.


Reply to this email directly or view it on GitHub:
#26 (comment)

@FroMage
Copy link
Owner

FroMage commented Mar 14, 2012

OK thanks a lot. I don't need tidying (but feel free to if you want), I need to see an example of what this does :) And documentation.

So @link is supported by SeeTag, OK that makes sense. That will need documenting too. Does it work for any reference to a java type, including JDK types like regular javadoc's @link?

I guess I'll need to add support for it in the other doclets too.

@FroMage
Copy link
Owner

FroMage commented Mar 14, 2012

For info, @link support was first requested in #1

@timw
Copy link
Author

timw commented Mar 14, 2012

Tidying was just getting the docs + test cases up to date so you could see what was going on.
I also wanted to fix the DTO documentation so it works on JavaBean style getters (currently naively does fields).

The implementation just delegates to the standard implementation for links that don't resolve to resource methods, so it should work for standard Java behaviour.
(One side effect of this is that if you create an invalid link, it'll still put it in as if you were pointing to a Java object).

cheers
tim

----- Original Message -----

From: "Stéphane Épardaud" reply@reply.github.com
To: "Tim Whittington" Tim.Whittington@orionhealth.com
Sent: Wednesday, 14 March, 2012 11:26:35 PM
Subject: Re: [jax-doclets] Pull Pojo DTO documentation, report layout and link handling (#26)

OK thanks a lot. I don't need tidying (but feel free to if you want), I need to see an example of what this does :) And documentation.

So @link is supported by SeeTag, OK that makes sense. That will need documenting too. Does it work for any reference to a java type, including JDK types like regular javadoc's @link?

I guess I'll need to add support for it in the other doclets too.


Reply to this email directly or view it on GitHub:
#26 (comment)

@MaggieLeber
Copy link

Be very happy to see this in a release; I'm likely not jiggy enough with git to test it before then.

timw added 13 commits April 10, 2012 11:48
…ntation to complement the jaxrs and jaxrs-minimal.
…ake documented paths for root resource methods consistent with other resource methods.
…in the Pojo type generation:

* Objects
* Documentation of properties based on JavaBean style methods
* Polymorphic DTOs
* Enumerated types
* Handling of parameterized types (where the type parameters should be documented, but not the generic type)
… discover documentable DTOs in generic collections.
… property accessors (rather than fields).

This is more likely to be what JSON serializers (such as Jackson) use (although there is a lot of flexibility in these tools around method and visibility rules).
Future work might require looking at fields, a bunch of serializer specific annotations, and using configuration options to the docket (for the config based serialization policies that can't be derived from code).
These are displayed distinctly in the data object list, and have a different style in the data object detail (modeled after the Javadoc presentation of enums).
… accessors.

This could probably be better done by adding per-serializer modes, but this is the most common case.
- -matchresourcesonly configuration option
- Support for Class factory based resource locator methods
- Linking (via {@link fu} inline doclets) in JAX-RS documentation
- POJO JSON documentation
Conflicts:
	doclets/src/main/java/com/lunatech/doclets/jax/jaxrs/JAXRSDoclet.java
	doclets/src/main/java/com/lunatech/doclets/jax/jaxrs/model/Resource.java
	doclets/src/main/java/com/lunatech/doclets/jax/jaxrs/model/ResourceMethod.java
	doclets/src/main/java/com/lunatech/doclets/jax/jaxrs/writers/MethodWriter.java
	doclets/src/main/java/com/lunatech/doclets/jax/writers/DocletWriter.java
@timw
Copy link
Author

timw commented Apr 10, 2012

OK, I've finally found some time to work on this.

  • Documentation for new features is now there
  • An example set of resources/DTOs for POJO JSON mode is now present, and has an integration-test phase to build it
  • POJO JSON mode now uses JavaBean style property accessors (previously it was just looking at fields)
  • Enumerated types are now documented properly
  • Some fixes to handling of types used in parameterized types (i.e. they now get documented)
  • Fixed some minor formatting issues
  • Merged with head (hopefully not borking anything in resolving the conflicts)

@timw
Copy link
Author

timw commented Apr 10, 2012

On the subject of @link, it works for:

  • resource (and resource locator) classes
  • resource methods

These two were the additions I made.

It also (due to built-in JavaDoc functionality) works with:

  • links to externally generated documentation (as long as they obey the standard layout rules), so JAXB docs, JDK documentation links all work
  • links to documented POJOs (for the same reason) also work

timw added 3 commits April 12, 2012 10:16
Included tests for invalid DTO, resource class and resource method @links.

Also made the link generation more resilient and focused - it only tries to look for resource methods if it found a resource class now.
Test examples also included.
@FroMage
Copy link
Owner

FroMage commented Jul 24, 2012

OK, this is fantastic work, thanks a lot!

FroMage added a commit that referenced this pull request Jul 24, 2012
Pull Pojo DTO documentation, report layout and link handling
@FroMage FroMage merged commit 9e94998 into FroMage:master Jul 24, 2012
@FroMage
Copy link
Owner

FroMage commented Jul 24, 2012

@timw if you want to become committer on jax-doclets, let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants