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 computed external links? #1343

Open
ThomasBreuer opened this issue Jun 17, 2020 · 5 comments
Open

support computed external links? #1343

ThomasBreuer opened this issue Jun 17, 2020 · 5 comments
Labels
Status: Speculative It's unknown if this is something that we wan't to do Type: Feature Type: Plugin A feature that should be implemented as a separate package.

Comments

@ThomasBreuer
Copy link

As far as I understand, Documenter.jl supports internal links via @ref, and external links via the [text](URL) syntax, where URL must be an explicit address.
I am trying to use Documenter.jl for a module that cross-references various entries in the documentation of some other computer system.
The URLs in question may be subject to changes, for example depending on the version number of that system; hard-coded URLs are therefore not a good solution.
At the time when the documentation of the module gets built, these URLs can be computed by a Julia function that belongs to the module.
Would it be possible to extend Documenter.jl such that this kind of computed external links gets supported, or do you have a better idea for this functionality?

Currently I am using the following hack.
Write [text](url-encode) in the documentation, let Documenter.jl process it, and add a post-processing step that replaces each url-encode by the computed URL.
This works in the final HTML version of the documentation, and looks acceptable in the interactive Julia help. However, Documenter.jl issues warnings about invalid local link.

@fredrikekre
Copy link
Member

fredrikekre commented Jun 17, 2020

Currently I am using the following hack.
Write text in the documentation, let Documenter.jl process it, and add a post-processing step that replaces each url-encode by the computed URL.
This works in the final HTML version of the documentation, and looks acceptable in the interactive Julia help. However, Documenter.jl issues warnings about invalid local link.

If you just replace it in a preprocess step instead it should not complain.

@ThomasBreuer
Copy link
Author

Thanks for your reply.
The point is that the links occur in docstrings inside the Julia code files. Programmatically rewriting the code files whenever the documentation gets processed sounds risky.

@c42f
Copy link

c42f commented Jun 23, 2020

It would be great if Documenter allowed the user to customize the logic for @ref lookup.

For JuliaHub we now build and serve most package documentation, and allowing @ref to link documentation between packages would provide a very cohesive user experience.

XRef: #319

@mortenpi mortenpi mentioned this issue Jul 3, 2020
@mortenpi mortenpi added Status: Speculative It's unknown if this is something that we wan't to do Type: Feature Type: Plugin A feature that should be implemented as a separate package. labels Jul 16, 2020
@mortenpi
Copy link
Member

Some sort of a hook into link generation is definitely something we could do, but I feel that this would need to be hashed out a bit more before it's actionable. Another question is whether we want to overload at-ref -- perhaps a dedicated at-link would make more sense?

However, for the OPs use case, a plugin might be the way to go. You can basically add another build stage that would expand a custom at-ref for you. You can take a look at the implementation of @cite and the discussion in #1162 (comment) (the hook into Documenter is here).

ThomasBreuer added a commit to ThomasBreuer/GAP.jl that referenced this issue Jul 16, 2020
a clean solution to compute external references

Preliminary support for computed external references in the documentation
of GAP.jl had been proposed in pull request oscar-system#472,
but this was of course not satisfactory because it misused Documenter.jl.

In the discussion of JuliaDocs/Documenter.jl/issues/1343,
@mortenpi suggested to get the required functionality by adding a plugin
to Documented.jl, analogous to an implementation of citations by @ali-ramadhan.
This works well, and from my point of view the issue JuliaDocs/Documenter.jl/issues/1343 can be closed.

Thanks a lot to @mortenpi for the hint, and to @ali-ramadhan for the code.

The details of the changes are:

- added a plugin for Documenter.jl
- replaced the GAP function `UrlOfManualEntry` by `MatchURLs`
  (thanks to @frankluebeck for this code)
- removed the now unnecessary GAP function `ComputeLinksToGAPManuals` and the Julia function `compute_links_to_gap_manuals`
fingolfin pushed a commit to oscar-system/GAP.jl that referenced this issue Jul 21, 2020
a clean solution to compute external references

Preliminary support for computed external references in the documentation
of GAP.jl had been proposed in pull request #472,
but this was of course not satisfactory because it misused Documenter.jl.

In the discussion of JuliaDocs/Documenter.jl/issues/1343,
@mortenpi suggested to get the required functionality by adding a plugin
to Documented.jl, analogous to an implementation of citations by @ali-ramadhan.
This works well, and from my point of view the issue JuliaDocs/Documenter.jl/issues/1343 can be closed.

Thanks a lot to @mortenpi for the hint, and to @ali-ramadhan for the code.

The details of the changes are:

- added a plugin for Documenter.jl
- replaced the GAP function `UrlOfManualEntry` by `MatchURLs`
  (thanks to @frankluebeck for this code)
- removed the now unnecessary GAP function `ComputeLinksToGAPManuals` and the Julia function `compute_links_to_gap_manuals`
@goerz
Copy link
Member

goerz commented Jan 7, 2024

DocumenterInterLinks.jl should provide a solution to this, although it's still experimental.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Speculative It's unknown if this is something that we wan't to do Type: Feature Type: Plugin A feature that should be implemented as a separate package.
Projects
None yet
Development

No branches or pull requests

5 participants