Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial UI sections docs pages and script for generation #114

Open
wants to merge 43 commits into
base: main
Choose a base branch
from

Conversation

dalthviz
Copy link
Member

@dalthviz dalthviz commented Feb 23, 2023

Description

Initial structure for UI sections documentation, support to render mermaid diagrams inside the documentation and a script to generate the UI sections documentation pages

Type of change

  • Adds new content page(s)

References

closes #93

Final checklist:

  • My PR is the minimum possible work for the desired functionality
  • I have commented my code, particularly in hard-to-understand areas
  • I have added alt text to new images included in this PR

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Feb 23, 2023
@dalthviz dalthviz changed the title Add initial UI sections docs generation Add initial UI sections docs pages and script Feb 23, 2023
@github-actions github-actions bot added the task label Feb 24, 2023
@github-actions github-actions bot removed the task label Feb 24, 2023
@dalthviz dalthviz changed the title Add initial UI sections docs pages and script Add initial UI sections docs pages and script for generation Feb 24, 2023
@dalthviz dalthviz marked this pull request as ready for review February 24, 2023 18:24
@psobolewskiPhD
Copy link
Member

I think this is great! I have a hard time figuring out where in the code base something is—like recently wanting to change the behavior of the visibility eye button.
While the maps are quite complex for me, the tree structure shows me quite clearly what parts of the codebase are linked together for those key UI elements.
(Also, I love your plugin for exploring the GUI!!)

@dalthviz
Copy link
Member Author

dalthviz commented Mar 6, 2023

Thanks for the feedback @psobolewskiPhD ! Yes, sometimes the diagrams are still a little bit convoluted, could it be worthy to try to group the nodes in subgraphs in some way to help with that?

Happy to hear that you checked out the plugin and the directory layout helps!

@dalthviz
Copy link
Member Author

dalthviz commented Mar 6, 2023

Just in case, experimenting a little bit with mermaid subgraphs and using the directory where the detected module is located, the diagram could look something like this (for example for the Applications menus page):

Application menus

Dependencies diagram (related napari modules)

graph LR
	napari._qt(napari._qt)
	napari._qt --> napari._qt.qt_main_window
	click napari._qt "https://github.com/napari/napari/tree/main/napari/_qt/__init__.py" _blank
	napari._qt._qapp_model.qactions(napari._qt._qapp_model.qactions)
	napari._qt._qapp_model.qactions --> napari._qt.qt_main_window
	click napari._qt._qapp_model.qactions "https://github.com/napari/napari/tree/main/napari/_qt/_qapp_model/qactions/__init__.py" _blank
	napari._qt.dialogs.preferences_dialog(napari._qt.dialogs.preferences_dialog)
	click napari._qt.dialogs.preferences_dialog "https://github.com/napari/napari/tree/main/napari/_qt/dialogs/preferences_dialog.py" _blank
	napari._qt.dialogs.qt_plugin_dialog(napari._qt.dialogs.qt_plugin_dialog)
	napari._qt.dialogs.qt_plugin_dialog --> napari._qt.qt_resources
	napari._qt.dialogs.qt_plugin_dialog --> napari._qt.widgets
	click napari._qt.dialogs.qt_plugin_dialog "https://github.com/napari/napari/tree/main/napari/_qt/dialogs/qt_plugin_dialog.py" _blank
	napari._qt.dialogs.qt_plugin_report(napari._qt.dialogs.qt_plugin_report)
	click napari._qt.dialogs.qt_plugin_report "https://github.com/napari/napari/tree/main/napari/_qt/dialogs/qt_plugin_report.py" _blank
	napari._qt.dialogs.qt_reader_dialog(napari._qt.dialogs.qt_reader_dialog)
	click napari._qt.dialogs.qt_reader_dialog "https://github.com/napari/napari/tree/main/napari/_qt/dialogs/qt_reader_dialog.py" _blank
	napari._qt.dialogs.screenshot_dialog(napari._qt.dialogs.screenshot_dialog)
	click napari._qt.dialogs.screenshot_dialog "https://github.com/napari/napari/tree/main/napari/_qt/dialogs/screenshot_dialog.py" _blank
	napari._qt.menus(napari._qt.menus)
	napari._qt.menus --> napari._qt.menus.debug_menu
	napari._qt.menus --> napari._qt.menus.file_menu
	napari._qt.menus --> napari._qt.menus.plugins_menu
	napari._qt.menus --> napari._qt.menus.window_menu
	click napari._qt.menus "https://github.com/napari/napari/tree/main/napari/_qt/menus/__init__.py" _blank
	napari._qt.menus._util(napari._qt.menus._util)
	click napari._qt.menus._util "https://github.com/napari/napari/tree/main/napari/_qt/menus/_util.py" _blank
	napari._qt.menus.debug_menu(napari._qt.menus.debug_menu)
	napari._qt.menus.debug_menu --> napari._qt.menus._util
	napari._qt.menus.debug_menu --> napari._qt.qt_main_window
	click napari._qt.menus.debug_menu "https://github.com/napari/napari/tree/main/napari/_qt/menus/debug_menu.py" _blank
	napari._qt.menus.file_menu(napari._qt.menus.file_menu)
	napari._qt.menus.file_menu --> napari._qt.dialogs.preferences_dialog
	napari._qt.menus.file_menu --> napari._qt.dialogs.qt_reader_dialog
	napari._qt.menus.file_menu --> napari._qt.dialogs.screenshot_dialog
	napari._qt.menus.file_menu --> napari._qt.menus._util
	napari._qt.menus.file_menu --> napari._qt.qt_main_window
	click napari._qt.menus.file_menu "https://github.com/napari/napari/tree/main/napari/_qt/menus/file_menu.py" _blank
	napari._qt.menus.plugins_menu(napari._qt.menus.plugins_menu)
	napari._qt.menus.plugins_menu --> napari._qt.dialogs.qt_plugin_dialog
	napari._qt.menus.plugins_menu --> napari._qt.dialogs.qt_plugin_report
	napari._qt.menus.plugins_menu --> napari._qt.menus._util
	napari._qt.menus.plugins_menu --> napari._qt.qt_main_window
	click napari._qt.menus.plugins_menu "https://github.com/napari/napari/tree/main/napari/_qt/menus/plugins_menu.py" _blank
	napari._qt.menus.window_menu(napari._qt.menus.window_menu)
	napari._qt.menus.window_menu --> napari._qt.menus._util
	napari._qt.menus.window_menu --> napari._qt.qt_main_window
	click napari._qt.menus.window_menu "https://github.com/napari/napari/tree/main/napari/_qt/menus/window_menu.py" _blank
	napari._qt.qt_main_window(napari._qt.qt_main_window)
	napari._qt.qt_main_window --> napari._qt._qapp_model.qactions
	napari._qt.qt_main_window --> napari._qt.menus
	napari._qt.qt_main_window --> napari._qt.qt_resources
	napari._qt.qt_main_window --> napari._qt.widgets
	click napari._qt.qt_main_window "https://github.com/napari/napari/tree/main/napari/_qt/qt_main_window.py" _blank
	napari._qt.qt_resources(napari._qt.qt_resources)
	click napari._qt.qt_resources "https://github.com/napari/napari/tree/main/napari/_qt/qt_resources/__init__.py" _blank
	napari._qt.widgets(napari._qt.widgets)
	click napari._qt.widgets "https://github.com/napari/napari/tree/main/napari/_qt/widgets/__init__.py" _blank
	subgraph module.napari[napari]
		 napari._qt
	end
	class module.napari subgraphs
	subgraph module.napari._qt._qapp_model[napari._qt._qapp_model]
		 napari._qt._qapp_model.qactions
	end
	class module.napari._qt._qapp_model subgraphs
	subgraph module.napari._qt.dialogs[napari._qt.dialogs]
		 napari._qt.dialogs.preferences_dialog
		 napari._qt.dialogs.qt_plugin_dialog
		 napari._qt.dialogs.qt_plugin_report
		 napari._qt.dialogs.qt_reader_dialog
		 napari._qt.dialogs.screenshot_dialog
	end
	class module.napari._qt.dialogs subgraphs
	subgraph module.napari._qt[napari._qt]
		 napari._qt.menus
		 napari._qt.qt_main_window
		 napari._qt.qt_resources
		 napari._qt.widgets
	end
	class module.napari._qt subgraphs
	subgraph module.napari._qt.menus[napari._qt.menus]
		 napari._qt.menus._util
		 napari._qt.menus.debug_menu
		 napari._qt.menus.file_menu
		 napari._qt.menus.plugins_menu
		 napari._qt.menus.window_menu
	end
	class module.napari._qt.menus subgraphs
	classDef subgraphs fill:white,strock:black,color:black;	classDef default fill:#00c3ff,color:black;
	linkStyle default stroke:#00c3ff
	classDef external fill:#ffa600,color:black;
Loading

Source code directory layout (related to modules inside napari)

napari/
└─_qt/
  ├─dialogs/
  │ ├─preferences_dialog.py
  │ ├─qt_plugin_dialog.py
  │ ├─qt_plugin_report.py
  │ ├─qt_reader_dialog.py
  │ └─screenshot_dialog.py
  ├─menus/
  │ ├─debug_menu.py
  │ ├─file_menu.py
  │ ├─plugins_menu.py
  │ ├─window_menu.py
  │ ├─_util.py
  │ └─__init__.py
  ├─qt_main_window.py
  ├─qt_resources/
  │ └─__init__.py
  ├─widgets/
  │ └─__init__.py
  ├─_qapp_model/
  │ └─qactions/
  │   └─__init__.py
  └─__init__.py

@psobolewskiPhD
Copy link
Member

That looks cool! are the zoom/pan controls a markdown thing only?

@dalthviz
Copy link
Member Author

dalthviz commented Mar 6, 2023

Awesome! And regarding the zoom controls I think is something GitHub added when it is rendering mermaid diagrams, not totally sure if there is a way to add that to the generated documentation but I can check 👍

@dalthviz
Copy link
Member Author

dalthviz commented Mar 8, 2023

Did a little exploration of how to add zoom capabilities to the diagram rendering and I got this:

docs-zoom

This uses d3 to enable the zoom

@psobolewskiPhD
Copy link
Member

Really dig this!
Slightly off topic: I think that we need to rethink our top-level menus to make dev/contributing stuff easier to find, because Community is probably not too logical for this?
cc: @melissawm
Maybe we need a top level thing for dev/contriuting that folds in the API reference and other dev centric things.

@dalthviz
Copy link
Member Author

Just in case, I was checking the top-level navigation of the page and seems like the API reference part could be though as part of the Usage section (is kind of a reference for the public API of napari which could help users use napari programatically from what I understand)? Maybe the idea to have API reference as a top-level entry is for easy access? Also, after checking, I think too it could make sense to add a top-level navigation entry with the Contributing resources section for discoverability 👍 Anyhow, maybe a new issue should be created to better discuss these sections organization ideas?

@dalthviz dalthviz marked this pull request as ready for review August 27, 2024 19:57
@melissawm
Copy link
Member

@dalthviz is this ready for another round of reviews?

@dalthviz
Copy link
Member Author

Yep @melissawm ! 👍

@dalthviz dalthviz closed this Dec 18, 2024
@dalthviz dalthviz reopened this Dec 18, 2024
@psobolewskiPhD
Copy link
Member

This is super cool! But I'm not getting the ability to zoom at least with the CircleCI docs
https://output.circle-artifacts.com/output/job/4c5e2695-c613-4305-9aaf-a74f0a5002b6/artifacts/0/docs/docs/_build/html/developers/architecture/ui_sections/application_status_bar_ui.html
image

Tried in Safari and Chrome -- am I missing something?

@dalthviz
Copy link
Member Author

Seems like something changed with the latest sphinxcontrib.mermaid extension release since constraining the extension version to be <1.0.0 makes things work 🤔

@dalthviz
Copy link
Member Author

@psobolewskiPhD I think I was able to change the mermaid related config for it to work again (nodes should show names, be clickable and you should be able to pan and zoom the diagrams). Let me know if you still see issues!

@psobolewskiPhD
Copy link
Member

Awesome! Yeah pan and zoom work great now.
Not a blocker, but the way our layout works is that making the window wider never makes the diagram bigger. It would be nice to have a way to pop it to a new tab/window to be able to make it larger.
Any ideas how that could be done? Could save it for a followup, but I think it would be very valuable to get the most out of the diagrams.

@psobolewskiPhD
Copy link
Member

Oh! And what do you think of linking to your awesome plugin on the UI sections landing page
https://github.com/dalthviz/napari-ui-tracer

@dalthviz
Copy link
Member Author

Not a blocker, but the way our layout works is that making the window wider never makes the diagram bigger. It would be nice to have a way to pop it to a new tab/window to be able to make it larger.
Any ideas how that could be done?

Maybe some custom code could enable doing something like opening the diagram in a new window indeed. As a quick check, something like the following could be achieved (kind of like taking a snapshot of the current zoom level/part of the diagram currently being viewed and showing that in a new tab/window):

docs_diagrams_ext_win

Note that the preview above was done by running some custom code (https://stackoverflow.com/a/56110734) + adding a new HTML node (click link) via the browser development tooling to trigger the code.

Oh! And what do you think of linking to your awesome plugin on the UI sections landing page
https://github.com/dalthviz/napari-ui-tracer

If that could be useful to have over the docs sure 👍 Is there any phrasing that should be used for the link? Maybe something like:

Also, a plugin to inspect how specific UI elements/widgets are defined
over the napari source code is available (https://github.com/dalthviz/napari-ui-tracer)

?

@psobolewskiPhD
Copy link
Member

I like that phrasing @dalthviz !
Let's open an issue for the pop-out of the diagrams.

Copy link
Member

@psobolewskiPhD psobolewskiPhD left a comment

Choose a reason for hiding this comment

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

I like this a lot.
For a followup issue we can try to figure a way to make the size responsive (could be hard because the container column is fixed width) or a pop out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
Status: Needs review
Development

Successfully merging this pull request may close these issues.

Add documentation mapping visual UI with code structure, modules and classes
4 participants