Skip to content

nim doc --project broken with imports below main project file or duplicate names #13150

Closed
@timotheecour

Description

@timotheecour

nim doc --project doesn't work when:

  • there are relative imports eg import ".." / utils
  • there are multiple modules in the project with the same basename

Example

nim doc --index:on --project --outdir:htmldocs /pathto/msub/main.nim

# /pathto/msub/main.nim:
from ".."/utils as m1 import nil 
from "."/utils as m2 import nil # note: would still be buggy if that clashing module is imported from somewhere else

# /pathto/msub/utils.nim
proc fun1*() = discard
# /pathto/utils.nim
proc fun2*() = discard

Current Output

  • depending on which import comes first, (from "."/utils as m2 import nil or from ".."/utils as m1 import nil), you'll get one module generated or the other (clashing location)
  • you'll get a 404 error when clicking on the import ../utils as the link will be wrong

Possible Solution

the most robust solution is to flatten the hierarchy in exactly the same way as done for nim c

find /tmp/d28/*.c
/tmp/d28/@[email protected]
/tmp/d28/@mthello2.nim.c
/tmp/d28/@mthello3.nim.c
/tmp/d28/stdlib_io.nim.c
/tmp/d28/stdlib_system.nim.c

perhaps the particular mangling scheme can be adapted for urls but idea is identical.

note

One additional advantage of a flat hierarchy is that we'd be able to use relative instead of absolute href:

 href <link rel="stylesheet" type="text/css" href="nimdoc.css"> # instead of `href="/nimdoc.css"`

and it would work with both httpserver and open pathto/main.html
currently both absolute and relative hrefs would not work depending on situations

Additional Information

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions