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

Unspecified HTML anchor in modelica URI needs clarification #2445

Closed
beutlich opened this issue Nov 3, 2019 · 12 comments · Fixed by #2531
Closed

Unspecified HTML anchor in modelica URI needs clarification #2445

beutlich opened this issue Nov 3, 2019 · 12 comments · Fixed by #2531
Labels
decided A decision has been made (label added before the spec is changed)
Milestone

Comments

@beutlich
Copy link
Member

beutlich commented Nov 3, 2019

It does not seem possible to refer to HTML anchors within the modelica URI, see the following proof of concept, which does not work in Dymola 2020, SimulationX 4.0 or WSM 12.

model Test_Anchor "PoC for HTML anchor"
  annotation(
    Documentation(
      info="<html>
<p>See <a href=\"modelica://ModelicaReference.ModelicaGrammar#import_clause\">import_clause</a> in the Modelica Grammar.
</p></html>"),
    uses(ModelicaReference(version="3.2.3")));
end Test_Anchor;
@HansOlsson
Copy link
Collaborator

I would say that this wasn't part of the design, since the specification says:

Together with scheme “Modelica” the (URI) fragment specifiers #diagram, #info, #text, #icon may > be used to reference different layers. Example:
<a href="Modelica://MultiBody.Joints.Revolute#info">Revolute</a>

I don't see any indication that other fragments should be supported in the current specification.

Obviously it would still be a good idea to support both layers and parts like this - we just need to avoid ambiguities; and ensure that it goes together with some minor cleanup of Modelica URI schemas that is already planned..

@maltelenz
Copy link
Collaborator

If you replace the / with . in the example model, it will work in SystemModeler 12.1. We had a bug with anchors in general in 12.0.

I don't see a reason why this shouldn't work.

model Test_Anchor "PoC for HTML anchor"
  annotation(
    Documentation(
      info="<html>
<p>See <a href=\"modelica://ModelicaReference.ModelicaGrammar#import_clause\">import_clause</a> in the Modelica Grammar.
</p></html>"),
    uses(ModelicaReference(version="3.2.3")));
end Test_Anchor;

@beutlich
Copy link
Member Author

beutlich commented Nov 5, 2019

  • True, the PoC model needs to be corrected. I edited above.
  • There are ambiguities if the anchor is named #diagram, #info, #text, or #icon.

@maltelenz
Copy link
Collaborator

I agree there are ambiguities for #diagram, #info #text and #icon. In my opinion, we would be fine with defining those to always have the specific meaning of referencing the layers. If you want to use anchors in pages, you can then name them something different.

@HansOlsson
Copy link
Collaborator

I just realized that this is actually a bit more complicated in general:

In Dymola (and several other tools) we also generate HTML-files from the documentation (with several options). That implies that we combine documentation-layers from several classes; and in turn that means that if several classes have identical anchors we would need to do something special.
Not impossible to handle - just something that needs to be considered; and I believe some library developers will in fact use the same anchor-names in many classes (e.g. "references", "asumptions").

Additionally Dymola (don't know about other tools) allow linking to components in diagram, icon and text-layers (the syntax is #diagram$e.f:g,h for selecting components g and h in the sub-component e.f; I'm not saying that the syntax is ideal). It seems as if this sort of corresponds to the anchors in the info-layer in some way - so it would be good if they were considered together.

(And then there are the new figures.)

And finally we have parts of the generated HTML that it may be natural to link to - e.g. table of parameters.

@maltelenz
Copy link
Collaborator

In SystemModeler, we don't currently export single HTML pages with multiple class documentation layers in it. We currently only do one page per class, like this: https://reference.wolfram.com/system-modeler/libraries/Modelica/Modelica.html
I think if tools combine classes, maybe it needs to be up to the generator in the tool to unique-ify anchors by modifying them in the generated result? I don't see another way around that.

Additionally Dymola (don't know about other tools) allow linking to components in diagram, icon and text-layers (the syntax is #diagram$e.f:g,h for selecting components g and h in the sub-component e.f; I'm not saying that the syntax is ideal). It seems as if this sort of corresponds to the anchors in the info-layer in some way - so it would be good if they were considered together.

I agree.

And finally we have parts of the generated HTML that it may be natural to link to - e.g. table of parameters.

I don't think the specification should get involved in this.

@henrikt-ma
Copy link
Collaborator

I would say that this wasn't part of the design, since the specification says:

Together with scheme “Modelica” the (URI) fragment specifiers #diagram, #info, #text, #icon may > be used to reference different layers. Example:
<a href="Modelica://MultiBody.Joints.Revolute#info">Revolute</a>

I don't see any indication that other fragments should be supported in the current specification.

Obviously it would still be a good idea to support both layers and parts like this - we just need to avoid ambiguities; and ensure that it goes together with some minor cleanup of Modelica URI schemas that is already planned..

Yes, when cleaning this up, I think it would be best to not use fragments for the layers. First, we have the obvious risk of collisions with user-defined anchor names. Second, a fragment appears at the end of the URI, but the layer (or figure) is a selection directly on the model. Since a colon is allowed in the path of a URI, we could do something like this instead to link to the anchor with name name in the documentation of Foo.Bar:

modelica:///Foo.Bar:info#name

This generalizes nicely to hierarchical documentation in the future:

modelica:///Foo.Bar:info/subtopic.html#name

For figures in the future, the fragment could be defined naturally refer to a figure or plot identifier:

modelica:///Foo.Bar:fig#id

@svorkoetter
Copy link
Collaborator

In SystemModeler, we don't currently export single HTML pages with multiple class documentation layers in it. We currently only do one page per class, like this: https://reference.wolfram.com/system-modeler/libraries/Modelica/Modelica.html

We do the same in MapleSim. We only export multiple classes per page when generating external documentation (i.e. intended for use in a stand-alone web browser).

@maltelenz
Copy link
Collaborator

We do the same in MapleSim. We only export multiple classes per page when generating external documentation (i.e. intended for use in a stand-alone web browser).

We only export one class per page in that case as well, but I can see why you would like the single page with everything in some scenarios.

@svorkoetter
Copy link
Collaborator

We only export one class per page in that case as well, but I can see why you would like the single page with everything in some scenarios.

Specifically, in that case we produce one HTML page per package, so the links to non-package classes within the package are all links to anchors.

@HansOlsson HansOlsson modified the milestones: Design100, Design101 Feb 11, 2020
@HansOlsson HansOlsson added the decided A decision has been made (label added before the spec is changed) label Feb 19, 2020
@HansOlsson
Copy link
Collaborator

Could keep anchors, but:

  1. Require that user-anchors for modelica:// are unique per package: 1
  2. Just state that user-anchors for modelica:// might be renamed: 2
    And user-anchors are supported. Rest abstain.

@HansOlsson
Copy link
Collaborator

Henrik: Also change predefined fragments from anchor to something else, to avoid ambiguity for figure-fragments.
That should be coordinated with changing from modelica:// to modelica:/// - due to case-issues, see other issues ...
(But this change is independent.)

HansOlsson added a commit to HansOlsson/ModelicaSpecification that referenced this issue Mar 16, 2020
Note that "fragment identifier" is the technical name for the id following #
https://en.wikipedia.org/wiki/Fragment_identifier
Whereas anchor is the anchor-point in the hypertext:
https://en.wikipedia.org/wiki/HTML_element#Anchor
Closes modelica#2445
HansOlsson added a commit that referenced this issue Mar 19, 2020
* Allow user defined fragments, and state that they may be renamed.
Closes #2445
* And follow URI-recommendation and use lower-case ("modelica://")

Co-authored-by: Dietmar Winkler <dietmar.winkler@dwe.no>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
decided A decision has been made (label added before the spec is changed)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants