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

Introduce a new URL for library pages, at index.html #3895

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

srawlins
Copy link
Member

@srawlins srawlins commented Oct 2, 2024

Fixes #1346

This "moves" the URL of each library from, e.g.
'package-two_lib2/package-two_lib2-library.html' to 'package-two_lib2/index.html', such that we can have links with 'package-two_lib2'. The old URLs are preserved via redirecting HTML files.

(HTTP redirects are more standard and recommended, but dartdoc does not contain an HTTP server; HTTP redirects could be implemented at the hosting server, which is different for different doc hosts (Google Storage, Firebase, ...). Instead we use simpler HTML redirects. In fact, a given backend host could use the HTML redirecting files as a database to inform HTTP redirect rules, that need to be implemented differently for each backend. So dartdoc now produces redirecting files, but a given backend could instead return an HTTP 301 Permanent Redirect response when requesting one of the redirecting files.)

This adds a negligible number of files (1 per documented library), and a negligible number of bytes (tiny redirect files), but actually is probably a net negative in terms of bytes, as many links are now shortened, removing the HTML file name of library URLs.


  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.
Contribution guidelines:

Note that many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.

@gspencergoog
Copy link
Collaborator

Would it make sense to have a mode that doesn't emit redirects at all, and renames the output files for all the symbol types that aren't suffixed, like variable, enum, and function (so the top level "index" variable doesn't collide with "index.html", etc.)? Then that mode could be used for "new" output, and the redirects could be used for "legacy" output. I'd hate to think that we're stuck emitting ever larger numbers of redirect files every time we rename something in the output tree.

@srawlins
Copy link
Member Author

srawlins commented Oct 2, 2024

We could have a mode that stops emitting the redirecting files. You'd enable it whenever you're comfortable with some % of broken links coming from StackOverflow, articles, etc.

@gspencergoog
Copy link
Collaborator

We could have a mode that stops emitting the redirecting files. You'd enable it whenever you're comfortable with some % of broken links coming from StackOverflow, articles, etc.

I was imagining using it mainly for new packages, so in those cases there wouldn't be any broken links.

@srawlins
Copy link
Member Author

srawlins commented Oct 2, 2024

Ah, we could do that. It wouldn't be used very much, as a new package author would have to know about it and include it in their dartdoc_options.yaml, or it could be the default and offer the "please don't break old links" mode be opt-in.

@gspencergoog
Copy link
Collaborator

Okay, maybe not worth the effort, then. Having it be the default might cause havoc (since people wouldn't know to turn it on and make lots of broken links), and having it not be the default means it won't be used much.

@srawlins srawlins force-pushed the index-html branch 4 times, most recently from 12113f2 to 64dda21 Compare October 8, 2024 17:14
Fixes dart-lang#1346

This "moves" the URL of each library from, e.g.
'package-two_lib2/package-two_lib2-library.html' to
'package-two_lib2/index.html', such that we can have links with
'package-two_lib2'. The old URLs are preserved via redirecting HTML files.

(HTTP redirects are more standard and recommended, but dartdoc does not contain
an HTTP server; HTTP redirects could be implemented at the hosting server,
which is different for different doc hosts (Google Storage, Firebase, ...).
Instead we use simpler HTML redirects. In fact, a given backend host could use
the HTML redirecting files as a database to inform HTTP redirect rules, that
need to be implemented differently for each backend. So dartdoc now produces
redirecting files, but a given backend could instead return an HTTP 301
Permanent Redirect response when requesting one of the redirecting files.)

This adds a negligible number of files (1 per documented library), and a
negligible number of bytes (tiny redirect files), but actually is probably a
net negative in terms of bytes, as many links are now shortened, removing the
HTML file name of library URLs.
@srawlins
Copy link
Member Author

Ready for review @dart-lang/analyzer-team . Big feature for dartdoc.

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

Successfully merging this pull request may close these issues.

Support default document (index.html) for cleaner URLs
3 participants