Skip to content

Use javadoc-extension #1914

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ngocnhan-tran1996
Copy link
Contributor

The main points:

  • The new Spring Authorization Server version document will be compatitable with Spring Framework version document
  • Reference javadoc will be easier, use javadoc:org.springframework.security... instead {spring-security-api-base-url}...

Signed-off-by: Tran Ngoc Nhan <ngocnhan.tran1996@gmail.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 21, 2025
Signed-off-by: Tran Ngoc Nhan <ngocnhan.tran1996@gmail.com>
Signed-off-by: Tran Ngoc Nhan <ngocnhan.tran1996@gmail.com>
@jgrandja jgrandja added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 5, 2025
@jgrandja jgrandja self-assigned this Mar 5, 2025
Copy link
Collaborator

@jgrandja jgrandja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @ngocnhan-tran1996. Please see review comments.

"spring-authorization-server-version": project.version
'spring-authorization-server-version': project.version,
'spring-security-reference-base-url': "https://docs.spring.io/spring-security/reference/${generateVersionWithoutPatch(springSecurityVersion)}".toString(),
'javadoc-location-org-springframework-security': "https://docs.spring.io/spring-security/site/docs/$springSecurityVersion/api".toString(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is correct?

I reviewed the changes in Spring Security spring-security#15386 and the gradle task syncAntoraAttachments was added which copies the javadoc as an asset to the site. I'm wondering if we need to do the same here?

@rwinch Is there a way to copy the Spring Security javadoc as an asset to the Spring Authorization Server site docs and reference it via a site asset? Or is this correct by directly referencing the Spring Security javadoc site?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rwinch As a side note, it appears syncAntoraAttachments is a required gradle task otherwise the antora build will fail saying it cannot find the javadoc resource. For example, after adding javadoc:org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationCode[], the build will fail unless I add the syncAntoraAttachments task. However, this is not documented in Javadoc, unless I'm missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have the way copy the Spring Security javadoc to to the Spring Authorization Server, please let me know

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rwinch Is there a way to copy the Spring Security javadoc as an asset to the Spring Authorization Server site docs and reference it via a site asset?

You should copy Spring Authorization Servers javadoc to the Antora site, but you should NOT copy Spring Security's Javadoc.

The javadoc extension is just syntactic sugar for creating a link to Javadoc and can operate in a numerous different ways. It creates a link and does NOT create/copy Javadoc in the location it is pointing to.

Linking to Spring Authorization Server Javadoc

The default mode is to use xref:attachment$api/java which, as an xref to an attachment, will be validated by Antora that the link exists. This means you can get validation of the javadoc links existing for free. You will use this mode for linking to Spring Authorization Server javadoc. Since the javadoc extension is just creating a link, you still need to ensure that the Javadoc is added.

Spring Security configures the Antora Collector Extension to invoke the generateAntoraResources task (and in turn generateAntoraYml and syncAntoraAttachments). The generateAntoraYml task is how dynamic properties like version are set properly and synAntoraAttachments is how the Javadoc is generated/added as attachments to the site. Once it is added to the site, the Javadoc is automatically published as a part of your site.

Linking to Other Module's Javadoc

As for linking to other module's Javadoc (e.g. Spring Security), you should NOT copy it. Instead use Package Specific Locations or Link Specific Locations. You will notice that these demonstrate ways that external sites can be linked to. In this case it is more obvious, but worth pointing out that the javadoc extension does not publish the javadocs. It is just syntactic sugar for creating a link to something that must already exist.

@jgrandja jgrandja changed the title Improve build.gradle for building antora Use Javadoc macro Mar 5, 2025
@jgrandja jgrandja changed the title Use Javadoc macro Use javadoc-extension Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants