2

I am trying to create a link to file2.py from file_1.py. For simplicity we can assume both are in the same package.

What I would do in Java (via Intellij) is using {@link AnotherClass} but this is not possible in Python comment (or Pycharm):

enter image description here

I also tried to use Sphinx and though it is possible to make such links with something like :py:mod:'my.package.file2' this doesn't work for me since I cannot use an IDE to navigate to the file and I also cannot generate these links easily since there is no autocomplete available to auto-generate the full module path.

Is there any other option I am missing? I am not restricted to any particulare IDE/Editor or any link format.

Yar
  • 7,020
  • 11
  • 49
  • 69

1 Answers1

0

You can use the extension HTML Related Links

Add this to your settings.json

  "html-related-links.include": {
    "python": [
      { "find": "\\{@link ([^}]+)\\}';", "filePath": "$1.py" }
    ]
  }

Now all the linked files are shown in the Related Files view in the Explorer bar (Ctrl+Shift+E). You can create files that do not exist yet by clicking on the create file icon in the view. Or when you try to open a non existing file you have to option to create it (button in the message).

I will try to make these new type of links Ctrl-clickable.

rioV8
  • 24,506
  • 3
  • 32
  • 49