Skip to content

Commit 957a4e3

Browse files
authored
Move user-facing information to top of preferences and fix autogenerated UI images (#613)
# References and relevant issues <!-- What relevant resources were used in the creation of this PR? If this PR addresses an existing issue on the repo, please link to that issue here as "Closes #(issue-number)". If this PR adds docs for a napari PR please add a "Depends on <napari PR link>" --> # Description <!-- What does this pull request (PR) do? Does it add new content, improve/fix existing context, improve/fix workflow/documentation build/deployment or something else? <!-- If relevant, please include a screenshot or a screen capture in your content change: "An image is worth a thousand words!" --> <!-- You can use https://www.cockos.com/licecap/ or similar to create animations. --> <!-- You can also see a preview of the documentation changes you are submitting by clicking on "Details" to the right of the "Check the rendered docs here!" check on your PR.--> 1. Moves user-facing information to the top of the autogenterated preferences document. 2. Removes the redundant programmatic settings code block (unless we also want to show the settings.SETTINGS version. I think as a learner, understanding how `get_settings()` is used to set a singleton was more important to my understanding) 3. Fixes/updates the autogenerated preferences dialog images to correctly match the header to the image, and update the UI to correctly show the selection in the list on the left. <!-- Final Checklist - If images included: I have added [alt text](https://webaim.org/techniques/alttext/) If workflow, documentation build or deployment change: - My PR is the minimum possible work for the desired functionality - I have commented my code, to let others know what it does -->
1 parent 12ac953 commit 957a4e3

File tree

1 file changed

+41
-35
lines changed

1 file changed

+41
-35
lines changed

docs/_scripts/update_preference_docs.py

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
2121
Starting with version 0.4.6, napari provides persistent settings.
2222
23-
Settings are managed by getting the global settings object:
23+
Settings are managed by getting the global settings object and modifying settings:
2424
2525
```python
2626
from napari.settings import get_settings
@@ -30,38 +30,6 @@
3030
settings.appearance.theme = 'dark'
3131
```
3232
33-
## Sections
34-
35-
The settings are grouped by sections and napari core provides the following:
36-
37-
{%- for section, section_data in sections.items() %}
38-
39-
### {{ section_data["title"]|upper }}
40-
41-
{{ section_data["description"] }}
42-
43-
{% for fields in section_data["fields"] %}
44-
#### {{ fields["title"] }}
45-
46-
*{{ fields["description"] }}*
47-
48-
* <small>Access programmatically with `SETTINGS.{{ section }}.{{ fields["field"] }}`.</small>
49-
* <small>Type: `{{ fields["type"] }}`.</small>
50-
* <small>Default: `{{ fields["default"] }}`.</small>
51-
{% if fields["ui"] %}* <small>UI: This setting can be configured via the preferences dialog.</small>{% endif %}
52-
{%- endfor -%}
53-
{% endfor %}
54-
55-
**Support for plugin specific settings will be provided in an upcoming release.**
56-
57-
## Changing settings programmatically
58-
59-
```python
60-
from napari.settings import SETTINGS
61-
62-
SETTINGS.appearance.theme = "light"
63-
```
64-
6533
## Reset to defaults via CLI
6634
6735
To reset all napari settings to the default values:
@@ -90,6 +58,30 @@
9058
9159
![{{ reset }}]({{ images_path }}/preferences-reset.png)
9260
61+
## Sections
62+
63+
The settings are grouped by sections and napari core provides the following:
64+
65+
{%- for section, section_data in sections.items() %}
66+
67+
### {{ section_data["title"]|upper }}
68+
69+
{{ section_data["description"] }}
70+
71+
{% for fields in section_data["fields"] %}
72+
#### {{ fields["title"] }}
73+
74+
*{{ fields["description"] }}*
75+
76+
* <small>Access programmatically with `SETTINGS.{{ section }}.{{ fields["field"] }}`.</small>
77+
* <small>Type: `{{ fields["type"] }}`.</small>
78+
* <small>Default: `{{ fields["default"] }}`.</small>
79+
{% if fields["ui"] %}* <small>UI: This setting can be configured via the preferences dialog.</small>{% endif %}
80+
{%- endfor -%}
81+
{% endfor %}
82+
83+
**Support for plugin specific settings will be provided in an upcoming release.**
84+
9385
"""
9486

9587

@@ -105,11 +97,25 @@ def generate_images():
10597
pref.show()
10698
QTimer.singleShot(1000, pref.close)
10799

108-
for idx, (name, field) in enumerate(NapariSettings.__fields__.items()):
100+
# Collect all sections first
101+
sections = [field.field_info.title or name
102+
for name, field in NapariSettings.__fields__.items()
103+
if isinstance(field.type_, ModelMetaclass)]
104+
105+
# Process each section with proper timing
106+
for idx, title in enumerate(sections):
107+
# Set current index
109108
pref._stack.setCurrentIndex(idx)
109+
pref._list.setCurrentRow(idx)
110+
111+
# Process events to ensure UI has updated
112+
app.processEvents()
113+
114+
# Capture screenshot
110115
pixmap = pref.grab()
111-
title = field.field_info.title or name
112116
pixmap.save(str(IMAGES_PATH / f"preferences-{title.lower()}.png"))
117+
118+
113119

114120
box = QMessageBox(
115121
QMessageBox.Icon.Question,

0 commit comments

Comments
 (0)