Skip to content

ENH: Build API entry usage graphs#12013

Merged
drammock merged 2 commits intomne-tools:mainfrom
larsoner:usage
Sep 26, 2023
Merged

ENH: Build API entry usage graphs#12013
drammock merged 2 commits intomne-tools:mainfrom
larsoner:usage

Conversation

@larsoner
Copy link
Copy Markdown
Member

Toward #11114, let's see if we can even get a graph to show and if it looks okay. If we can't, we should just close #11114 since the feature will not be usable for us.

If it does look okay, I'll add it to the docs somewhere and we can merge.

@larsoner larsoner marked this pull request as ready for review September 26, 2023 13:03
@larsoner larsoner changed the title WIP: Try building usage graphs ENH: Build API entry usage graphs Sep 26, 2023
@larsoner
Copy link
Copy Markdown
Member Author

@drammock ready for review/merge from my end

https://output.circle-artifacts.com/output/job/ebae1e27-a0ed-4229-a48d-2e7114b49bfd/artifacts/0/html/sg_api_usage.html

It's not perfect but it does give us some targets for things to add. After this is merged we can create a new issue, mark it as easy, and link to the mne.tools/dev version of the page.

Copy link
Copy Markdown
Member

@drammock drammock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice addition. Some comments:

  1. graph is basically unusable because the nodes are so small and spread out. Does the SG API let you adjust nodesep or other graphviz params?

  2. It's interesting to note that this has similar problems as the minigallery directive. Minigallery will (sometimes! not always) link from an API entry to a tutorial even if the func/meth/class is merely mentioned in the rST prose of the tutorial (i.e. not actually used in the executed code). An example is the mne.viz.plot_topomap minigallery's link to the working with sensor locations tutorial. An example where a method gets zero minigallery entries (despite mention in a tutorial) is Epochs.del_proj(), which is mentioned in the Epochs overview tutorial. It even sometimes fails to create a minigallery link when the API element is in executed code, as in Label.center_of_mass which gets no minigallery but is used in the point spread tutorial The "unused API entries" appears to have similar (the same?) problems.

@drammock
Copy link
Copy Markdown
Member

feel free to merge if you don't want to address those points / if they're best addressed upstream in SG (they probably are)

@larsoner
Copy link
Copy Markdown
Member Author

Yeah those are indeed all upstream SG issues

@larsoner
Copy link
Copy Markdown
Member Author

... except the node stuff. That we could probably change with this in conf.py:

graphviz_dot_args
Additional command-line arguments to give to dot, as a list. The default is an empty list.
This is the right place to set global graph, node or edge attributes via dot’s -G, -N and -E options.

@larsoner
Copy link
Copy Markdown
Member Author

With defaults I get:

Screenshot from 2023-09-26 12-27-18

With a bunch of stuff tweaked I get:

Screenshot from 2023-09-26 13-52-52

Visible here:

https://output.circle-artifacts.com/output/job/2383cbc7-250a-41c5-9f8b-32d51f73f904/artifacts/0/html/sg_api_usage.html

It's not perfect (there is some overlap) but it seems much more usable/readable.

@drammock drammock merged commit 079c868 into mne-tools:main Sep 26, 2023
@drammock
Copy link
Copy Markdown
Member

much better, thanks!

@larsoner larsoner deleted the usage branch September 26, 2023 18:43
@larsoner larsoner added the ENH label Oct 2, 2023
snwnde pushed a commit to snwnde/mne-python that referenced this pull request Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ENH] Use Sphinx-Gallery API Usage Map in Documentation

2 participants