bkryza / clang-uml

Customizable automatic UML diagram generator for C++ based on Clang.
Apache License 2.0
610 stars 44 forks source link

SVG links only work for source relative to the project directory #297

Closed bkryza closed 3 months ago

bkryza commented 3 months ago

Links in SVG diagrams currently are limited to files in project's directory, i.e. it's only possible to provide a single pattern which will append relative paths to the sources in links:

generate_links:
  link: 'https://github.com/myorg/myrepo/blob/{{ git.commit }}/{{ element.source.path }}#L{{ element.source.line }}'
  tooltip: '{% if "comment" in element %}{{ abbrv(trim(replace(element.comment.formatted, "\n+", " ")), 256) }}{% else %}{{ element.name }}{% endif %}'

It should be possible to specify absolute paths for link templates, which could allow adding links to external dependencies or even system headers, e.g.:

generate_links:
    link:
      ".": 'https://github.com/bkryza/clang-uml-examples/blob/{{ git.commit }}/{{ element.source.path }}#L{{ element.source.line }}'
      "/usr/include/c++/11": 'https://github.com/gcc-mirror/gcc/blob/releases/gcc-11.4.0/libstdc++-v3/include/{{ element.source.path }}#L{{ element.source.line }}'
    tooltip:
      ".": '{% if "comment" in element %}{{ abbrv(trim(replace(element.comment.formatted, "\n+", " ")), 256) }}{% else %}{{ element.name }}{% endif %}'
      "/usr/include/c++/11": ''

Also it should also allow dealing with relative paths inside the current project, e.g. for submodules.