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

Support javadoc lookup when package name has a single component #22

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions lib/javadoc-extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,11 @@ function createLinkMarkup (document, target, description, attributes) {

function getTargetLocation (document, target) {
let name = target.packageReference
let lastDot = name.lastIndexOf('.')
while (lastDot > 0) {
while (name !== '') {
const location = document.getAttribute('javadoc-location-' + name.replaceAll('.', '-'))
if (location) return location
name = name.substring(0, lastDot)
lastDot = name.lastIndexOf('.')
const lastDot = name.lastIndexOf('.')
name = lastDot > 0 ? name.substring(0, lastDot) : ''
}
return document.getAttribute('javadoc-location', 'xref:attachment$api/java')
}
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/include-code-extension-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ describe('include-code-extension', () => {
include-code::hello[sync-group-id=thisisauniqueid]
`
const actual = run(input, { registerAsciidoctorTabs: true })
console.log(actual.convert())
expect(actual.convert()).to.contain(
'class="openblock tabs is-sync data-sync-group-id=thisisauniqueid is-loading"'
)
Expand Down
19 changes: 19 additions & 0 deletions test/javadoc-extension-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,25 @@ describe('javadoc-extension', () => {
)
})

it('should convert with specified location when has single name package specific javadoc-location attributes', () => {
const input = heredoc`
= Page Title
:javadoc-location: xref:api:java
:javadoc-location-java: xref:api:e1
:javadoc-location-graphql: xref:api:e2

javadoc:java.util.ZipFile[]
javadoc:graphql.collect.ImmutableKit[]
`
const actual = run(input)
expect(actual).to.include(
'<a href="https://docs.example.com/api/e1/java/util/ZipFile.html" class="xref page apiref"><code>ZipFile</code></a>'
)
expect(actual).to.include(
'<a href="https://docs.example.com/api/e2/graphql/collect/ImmutableKit.html" class="xref page apiref"><code>ImmutableKit</code></a>'
)
})

it('should convert with specified location when has xref location in macro', () => {
const input = heredoc`
= Page Title
Expand Down
Loading