M2 icon indicating copy to clipboard operation
M2 copied to clipboard

relative paths in on-the-fly help

Open pzinn opened this issue 4 years ago • 1 comments

I'm not sure if this is really a bug, but this is something that's been bothering me for a while. currently, some links are broken in the help for me: they include source of packages and gold stars (!). an example:

i1 : needsPackage "Graphs"

o1 = Graphs

o1 : Package

i2 : help oo

o2 = Graphs
     ******

     Authors
     =======

       * Jack Burkart <[email protected]>
       * David Cook II (see http://ux1.eiu.edu/~dwcook/ ) <[email protected]>
       * Caroline Jansen <[email protected]>
       * Amelia Taylor <[email protected]>
       * Augustine O'Keefe <[email protected]>
       * Contributors of note: Carlos Amendola, Alex Diaz, Luis David Garcia Puente, Roser Homs Pons, Olga Kuznetsova,  Shaowei
         Lin, Sonja Mapes, Harshit J Motwani, Mike Stillman, Doug Torrance

     Version
     =======

     This documentation describes version 0.3.4 of Graphs.

     Source code
     ===========

     The source code from which this documentation is derived is in the file Graphs.m2 (see share/Macaulay2/Graphs.m2 ).
...

i3 :    peek oo#2#2#1


o3 = PARA{"The source code from which this documentation is derived is in the file ", HREF{"share/Macaulay2/Graphs.m2",
     -----------------------------------------------------------------------------------------------------------------------------
     "Graphs.m2"}, "."}

you can see that the path just starts with share/... unlike the other links that, at least with my version of M2, have the extra /usr.

pzinn avatar Nov 26 '21 05:11 pzinn

Probably what has to happen is for the treatment of the path in the HREF item provided by the call to the "toURL" function in the "html" method to be duplicated for the "net" method. The "html" method assumes the html will be deposited in the usual place for html documentation files, and the "net" method could create a link relative to the current directory.


i17 : methods HREF

o17 = {0 => (fixup, HREF)              }
      {1 => (html, HREF)               }
      {2 => (info, HREF)               }
      {3 => (markdown, HREF)           }
      {4 => (net, HREF)                }
      {5 => (NewFromMethod, HREF, List)}
      {6 => (tex, HREF)                }
      {7 => (validate, HREF)           }

o17 : NumberedVerticalList

i18 : code 1

o18 = -- code for method: html(HREF)
      src/M2/M2.git/M2/Macaulay2/m2/html.m2:136:16-140:66: --source code:
      html HREF := x -> (
           r := concatenate apply(splice if #x > 1 then drop(x, 1) else x, html1);
           r = if match("^ +$", r) then #r : "&nbsp;&nbsp;" else r;
           concatenate("<a href=\"", htmlLiteral toURL first x, "\">", r, "</a>")
           )

i19 : code 4

o19 = -- code for method: net(HREF)
      src/M2/M2.git/M2/Macaulay2/m2/format.m2:219:16-227:30: --source code:
      info HREF := x -> (
           if #x === 1 then x#0
           else if match ("^mailto:",x#0) then toString x#1
           -- x#0 is sometimes the relative path to the file, but not from the current directory
           else (
                r := horizontalJoin \\ net \ toList splice drop(x, 1);
                r | " (see " | x#0 | " )"
                )
           )

DanGrayson avatar Nov 26 '21 15:11 DanGrayson