startup: docs and features links under the logo instead of a printed tip
The full tip at every session start was too much. The banner now shows two links: the docs site and its random "Did you know?" page (did_you_know/random.html); eco.tip() still shows tips in a window.
This commit is contained in:
1 parent
4576ebcf18
commit
28aced6ded
4 files changed
+20
-26
No files matched your search
@@ -4,10 +4,11 @@ Short tips on eco features, newest first. Each one gives the main usage and
|
||||
what you gain from it, with a link to the full documentation where there is
|
||||
one. The collection so far covers features added since May 2026.
|
||||
|
||||
In an eco session, one tip is printed at startup (`ECO_NO_TIP=1` turns that
|
||||
off), and `eco.tip()` opens a small window where **Back** / **Next** go
|
||||
through the tips you have seen in this session and then on to new random
|
||||
ones. Without a display, `eco.tip()` prints the next tip instead.
|
||||
In an eco session, `eco.tip()` opens a small window where **Back** / **Next**
|
||||
go through the tips you have seen in this session and then on to new random
|
||||
ones. Without a display, it prints the next tip instead. On the docs site,
|
||||
`did_you_know/random.html` shows one random tip without the sidebar (linked
|
||||
from the session's startup banner).
|
||||
|
||||
```{toctree}
|
||||
:glob:
|
||||
|
||||
+6
-11
@@ -75,8 +75,13 @@ if arguments.scopes_available:
|
||||
|
||||
|
||||
print(
|
||||
" ___ _______\n / -_) __/ _ \ \n Experiment Control \__/\__/\___/ \n\n"
|
||||
" ___ _______\n / -_) __/ _ \ \n Experiment Control \__/\__/\___/ \n"
|
||||
)
|
||||
# Docs site and its "Did you know?" feature tips (eco.utilities.tips;
|
||||
# eco.tip() shows them in a window from the session).
|
||||
_docs_url = os.environ.get("ECO_DOCS_URL", "http://saresb-cons-04.psi.ch:8095/").rstrip("/")
|
||||
print(f" docs: {_docs_url}/")
|
||||
print(f" features: {_docs_url}/did_you_know/random.html (or eco.tip())\n")
|
||||
|
||||
term = Terminal(scope=scope)
|
||||
|
||||
@@ -191,13 +196,3 @@ if scope:
|
||||
)
|
||||
_ipymagic_root = eval(scope)
|
||||
ipymagic.start(_ipymagic_root)
|
||||
|
||||
# One "Did you know?" tip per session start, with a pointer to eco.tip()
|
||||
# for more in a window (eco.utilities.tips). ECO_NO_TIP=1 turns it off.
|
||||
if not os.environ.get("ECO_NO_TIP"):
|
||||
try:
|
||||
from eco.utilities import tips as _tips
|
||||
|
||||
_tips.print_tip(startup=True)
|
||||
except Exception as _exc:
|
||||
print(f"(no startup tip: {_exc})")
|
||||
@@ -4,10 +4,10 @@ The tips are the Markdown files in ``docs/did_you_know/`` (one per feature,
|
||||
``<date>-<slug>.md`` with a small front matter, see that folder's
|
||||
``index.md``) -- the same files the Sphinx docs show. Here they are:
|
||||
|
||||
- printed in the terminal, one at session start (``eco/startup_inline.py``;
|
||||
``ECO_NO_TIP=1`` turns that off), with a pointer to ``eco.tip()``;
|
||||
- shown in a small Qt window by ``eco.tip()`` (eco.widgets.tip_qt), or
|
||||
printed again where there is no display.
|
||||
printed in the terminal where there is no display. The session start
|
||||
(``eco/startup_inline.py``) only prints links to the docs site and its
|
||||
random-tip page.
|
||||
|
||||
Links to other docs pages (``{doc}`../scanning``` in a tip) point at the
|
||||
docs site, ``ECO_DOCS_URL`` (default: the server on saresb-cons-04).
|
||||
@@ -127,7 +127,7 @@ def get_tip(name):
|
||||
|
||||
class TipHistory:
|
||||
"""The tips shown in this session, in order, and where in that list we
|
||||
are -- shared by the startup tip, ``eco.tip()`` and the window's
|
||||
are -- shared by ``eco.tip()`` (printed or in the window) and the window's
|
||||
Back / Next buttons, like a browser history.
|
||||
|
||||
`next()` first walks forward through tips already shown (after going
|
||||
@@ -238,7 +238,7 @@ def as_text(tip, width=None, color=None):
|
||||
return "\n".join(out)
|
||||
|
||||
|
||||
def print_tip(tip=None, startup=False):
|
||||
def print_tip(tip=None):
|
||||
"""Print `tip` (default: the next one in this session's history, see
|
||||
TipHistory) in the terminal, framed as a "Did you know?" with a pointer
|
||||
to the window version."""
|
||||
@@ -250,8 +250,6 @@ def print_tip(tip=None, startup=False):
|
||||
print(f"{accent}Did you know?{reset}")
|
||||
print(textwrap.indent(as_text(tip, color=color), " "))
|
||||
hint = "eco.tip() shows more tips in a window"
|
||||
if startup:
|
||||
hint += " (ECO_NO_TIP=1 hides this at startup)"
|
||||
print(f"{accent}-> {hint}{reset}\n")
|
||||
return tip
|
||||
|
||||
@@ -262,7 +260,7 @@ def tip(name=None, window=None):
|
||||
e.g. "picker"); `window=True/False` forces the choice.
|
||||
|
||||
The window opens on the tip last shown in this session (e.g. the one
|
||||
printed at startup), so its Back / Next buttons continue that history.
|
||||
printed without a window), so its Back / Next buttons continue that history.
|
||||
Printing without a window moves on to the next tip.
|
||||
|
||||
Returns the window handle (``.next()``, ``.back()``, ``.stop()``) or the
|
||||
|
||||
+3
-3
@@ -78,10 +78,10 @@ def test_history_back_and_forth(tip_dir):
|
||||
|
||||
|
||||
def test_print_tip_records_in_history(tip_dir, capsys):
|
||||
shown = tips.print_tip(startup=True)
|
||||
shown = tips.print_tip()
|
||||
out = capsys.readouterr().out
|
||||
assert "Did you know?" in out and shown.title in out
|
||||
assert "eco.tip()" in out and "ECO_NO_TIP" in out
|
||||
assert "eco.tip()" in out
|
||||
assert tips.history.current.name == shown.name
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ def test_window_navigation(tip_dir, monkeypatch):
|
||||
monkeypatch.setenv("QT_QPA_PLATFORM", "offscreen")
|
||||
from eco.widgets import tip_qt
|
||||
|
||||
tips.print_tip() # the "startup" tip comes first
|
||||
tips.print_tip() # a tip printed earlier comes first
|
||||
startup = tips.history.current
|
||||
handle = tips.tip(window=True)
|
||||
try:
|
||||
|
||||
Reference in new issue
Block a user