Skip to content

Remove <base href> and emit absolute hrefs instead #2089

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

Closed
wants to merge 2 commits into from

Conversation

jdkoren
Copy link
Contributor

@jdkoren jdkoren commented Dec 11, 2019

Markdown will not be able to use <base href>; also, some hosting strategies might not favor its use. Instead we can make model elements have an absolute href by prefixing them with a /.

The major caveat is that the generated docs now must be served from the docs output directory, otherwise those absolute hrefs won't work. This will break clients that place generated docs in a subdirectoy of their served pages, whereas that previously worked fine.

#1479

hrefs for local libraries being documented are now absolute, starting
from the docs output directory. As a result, <base href> is no longer
necessary for these links to resolve.

Note that other hrefs (like static assets) must be adapted accordingly.
@googlebot googlebot added the cla: yes Google CLA check succeeded. label Dec 11, 2019
@devoncarew
Copy link
Member

We'd need to make sure that https://api.dartlang.org/ and https://flutter.dev/docs continue to work with this change.

@jdkoren
Copy link
Contributor Author

jdkoren commented Dec 11, 2019

We'd need to make sure that https://api.dartlang.org/ and https://flutter.dev/docs continue to work with this change.

Indeed. We're toying with an idea to add a DartdocOption<String> that will be prepended to hrefs for local packages. This way the pages can be served from an ancestor directory, but in that case it does mean clients would need to keep this option in sync with their hosting configuration, which is kind of unfortunate to impose on them.

We could try to keep the existing behavior and have the new behavior gated by some options. Something like

  • Keep the <base href> in the code
  • Add an option that controls whether <base href> is emitted, with default value true. In this case, DartDoc emits relative hrefs as before.
  • Add an option to supply a href prefix. Any value would change the above option to false and DartDoc will emit absolute hrefs.

@jcollins-g
Copy link
Contributor

I like the idea of introducing a flag that defaults to the old behavior for now. It would buy us the time we need to adapt downstream clients.

@jdkoren
Copy link
Contributor Author

jdkoren commented Dec 17, 2019

As per discussion in #2090, we are sticking with relative hrefs but using another approach which removes the <base> tag.

@jdkoren jdkoren closed this Dec 17, 2019
@jdkoren jdkoren deleted the htmlbase branch December 17, 2019 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Google CLA check succeeded.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants