Title: matplotlib.sphinxext.plot_directive generates incorrect links when using dirhtml builder · Issue #13858 · matplotlib/matplotlib · GitHub
Open Graph Title: matplotlib.sphinxext.plot_directive generates incorrect links when using dirhtml builder · Issue #13858 · matplotlib/matplotlib
X Title: matplotlib.sphinxext.plot_directive generates incorrect links when using dirhtml builder · Issue #13858 · matplotlib/matplotlib
Description: When using the dirhtml builder in sphinx with the .. plot:: directive, the generated links are relative to the source file tree not the output, i.e. the source file name become a directory containing index.html, however the relative path...
Open Graph Description: When using the dirhtml builder in sphinx with the .. plot:: directive, the generated links are relative to the source file tree not the output, i.e. the source file name become a directory containi...
X Description: When using the dirhtml builder in sphinx with the .. plot:: directive, the generated links are relative to the source file tree not the output, i.e. the source file name become a directory containi...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/13858
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"matplotlib.sphinxext.plot_directive generates incorrect links when using dirhtml builder","articleBody":"When using the `dirhtml` builder in sphinx with the `.. plot::` directive, the generated links are relative to the source file tree not the output, i.e. the source file name become a directory containing index.html, however the relative path generated is based on the location of the source file\r\nhttps://github.com/matplotlib/matplotlib/blob/ae73a46cc46045d7edac52ef3e8876515802f10d/lib/matplotlib/sphinxext/plot_directive.py#L740\r\n\r\nI fixed this locally using the the following hack, however I don't think this is the appropriate solution there should be some way to make the directive use the output path not the input path, which would remove the need for a hack solution. Hence I'm posting this as a issue rather than a patch.\r\n\r\n```python\r\n if setup.app.builder.name == 'dirhtml':\r\n subdir = os.path.basename(os.path.splitext(rst_file)[0])\r\n dest_dir_link = os.path.join(relpath(setup.confdir, os.path.join(rst_dir, subdir)),\r\n source_rel_dir).replace(os.path.sep, '/')\r\n else:\r\n dest_dir_link = os.path.join(relpath(setup.confdir, rst_dir),\r\n source_rel_dir).replace(os.path.sep, '/')\r\n```","author":{"url":"https://github.com/glenfletcher","@type":"Person","name":"glenfletcher"},"datePublished":"2019-04-03T04:05:46.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/13858/matplotlib/issues/13858"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:e2ef3d18-f693-bbd9-e77e-c3747f409238 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DF94:25C27F:10F39C0:16757CD:6A529B90 |
| html-safe-nonce | 15136a42668444b86b829a9433467a17190a708140c2ab5c556f29cf42239e1e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERjk0OjI1QzI3RjoxMEYzOUMwOjE2NzU3Q0Q6NkE1MjlCOTAiLCJ2aXNpdG9yX2lkIjoiNTc4OTI5MDg3Nzk2MTgwNDY4OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | bd9e2a62377ec1283b661d27e4a497f6bb029a51adfe23eaebe3518e8aa23d9d |
| hovercard-subject-tag | issue:428555679 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/13858/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2e95f2077219c2267e8adbbdf9d35b954dc737123b84fceb07ff8d925429af7c/matplotlib/matplotlib/issues/13858 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2e95f2077219c2267e8adbbdf9d35b954dc737123b84fceb07ff8d925429af7c/matplotlib/matplotlib/issues/13858 |
| og:image:alt | When using the dirhtml builder in sphinx with the .. plot:: directive, the generated links are relative to the source file tree not the output, i.e. the source file name become a directory containi... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | glenfletcher |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width