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

Update guides #1035

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions docs/source/development/guides.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,23 @@ Developers have two options when using the ``InAppGuide`` widget:
A decent amount of ``InAppGuide(identifier=<identifier>)`` instances have been placed strategically throughout the app.
Developers may suggest additional core guide sections via GitHub pull requests.
For plugin developers, additional instances of either flavor are recommended to be added in any component of the plugin in conjunction with dedicated plugin-specific guides.

Plugin guides
-------------

Plugin developers may introduce additional guides to the app. To do so, add the following key/value entry in your plugin's ``__init__.py`` file:

Choose a reason for hiding this comment

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

What about , "Plugin developers can enhance the user experience while using the app by introducing custom guides"


.. code:: python

my_plugin = {
...
"guides": <path-to-guide>,
}

where ``path-to-guide`` is the path (``Path`` object or absolute string path) to the directory containing the guide HTML files.

Choose a reason for hiding this comment

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

"Here, path_to_guide should be either a Path object or an absolute string path pointing to the directory that contains the guide HTML files."

On app start, the guide manager will scan the plugin entry points for the ``guides`` key and load the guides accordingly.

Guide order
-----------

When naming your guide HTML documents, prefix the file name with ``#_``. The number ``#`` will determine the order in which the guides are displayed in the list.

Choose a reason for hiding this comment

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

"To control the display order of your guide HTML documents, prefix each file name with #_, where # is a number. This number will dictate the order in which the guides appear in the list."

5 changes: 3 additions & 2 deletions src/aiidalab_qe/common/guide_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,12 @@ def _on_active_guide_change(self, _):

def _fetch_plugin_guides(self):
"""Fetch guides from plugins."""
entries: dict[str, Path] = get_entry_items("aiidalab_qe.properties", "guides")
entries: dict = get_entry_items("aiidalab_qe.properties", "guides")
for identifier, guides in entries.items():
path = Path(guides)
if identifier not in self._guides:
self._guides[identifier] = {}
for guide in sorted(guides.glob("*"), key=lambda x: x.stem.split("_")[0]):
for guide in sorted(path.glob("*"), key=lambda x: x.stem.split("_")[0]):
stem = guide.stem.split("_", maxsplit=1)[1]
self._guides[identifier][stem] = guide.absolute()

Expand Down
16 changes: 0 additions & 16 deletions src/aiidalab_qe/guides/1_advanced.html

This file was deleted.

4 changes: 0 additions & 4 deletions src/aiidalab_qe/plugins/bands/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# from aiidalab_qe.bands.result import Result
from pathlib import Path

from aiidalab_qe.common.panel import PluginOutline

from .model import BandsConfigurationSettingsModel
Expand All @@ -24,5 +21,4 @@ class BandsPluginOutline(PluginOutline):
"model": BandsResourceSettingsModel,
},
"workchain": workchain_and_builder,
"guides": Path(__file__).parent / "guides",
}
10 changes: 0 additions & 10 deletions src/aiidalab_qe/plugins/bands/guides/0_basic.html

This file was deleted.

7 changes: 1 addition & 6 deletions tests/test_infobox.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,8 @@ def test_in_app_guide():
assert in_app_guide.layout.display == "none"
guide_manager.active_guide = "general/basic"
assert in_app_guide.layout.display == "flex"
guide_manager.active_guide = "general/advanced"
assert in_app_guide.layout.display == "flex"
in_app_guide.guide_id = "general/advanced"
guide_manager.active_guide = "general/basic"
guide_manager.active_guide = "none"
assert in_app_guide.layout.display == "none"
guide_manager.active_guide = "general/advanced"
assert in_app_guide.layout.display == "flex"

guide_manager.active_guide = "general/basic"
in_app_guide = InAppGuide(identifier="guide-warning")
Expand Down
Loading