dartdoc
dartdoc copied to clipboard
Page styles and links broken on angular_components StepDirective page
The Problem
Visiting https://pub.dartlang.org/documentation/angular_components/0.9.0-beta/material_stepper_material_step/StepDirective results in an unstyled page:
The problem is that the page contains <base href="../..">
but the style files are at ..
.
Why its happening
The cause of the problem is that StepDirective
has a field named index
, and so the API doc page for this field is index.html
. A get request for
- https://pub.dartlang.org/documentation/angular_components/0.9.0-beta/material_stepper_material_step/StepDirective results in
- https://pub.dartlang.org/documentation/angular_components/0.9.0-beta/material_stepper_material_step/StepDirective/index.html being returned.
One might argue that we shouldn't be attempting to access https://pub.dartlang.org/documentation/angular_components/0.9.0-beta/material_stepper_material_step/StepDirective, but it isn't that simple as I explain next.
API docs on webdev.dartlang.org
For a server configured to support clean URLs w/o trailing slashes, a request for
- https://pub.dartlang.org/documentation/angular_components/0.9.0-beta/material_stepper_material_step/StepDirective/index.html
- Will be redirected (HTTP status code 301), to https://pub.dartlang.org/documentation/angular_components/0.9.0-beta/material_stepper_material_step/StepDirective
Solution ideas
A possible solution might be to have a dartdoc option in support of doc servers configured with clean URLs and no trailing slashes. This option would ensure that the base href for API pages named index.html
gets set to ..
rather than ../..
.
Another option might be to set the base href dynamically, but that might get tricky.
Note that in the meantime I've been manually patching the generated API docs, setting the base href to a proper value.
cc @kwalrath @kevmoo @nshahan