From ae838e5710508ba47c304b670d4c5a7af3388958 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Thu, 5 Oct 2023 16:15:19 +0200 Subject: [PATCH] DX: show all symbols in Jupyter notebook (#187) --- src/repoma/check_dev_files/__init__.py | 8 ++++---- src/repoma/check_dev_files/vscode.py | 18 +++++++++++++++--- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/repoma/check_dev_files/__init__.py b/src/repoma/check_dev_files/__init__.py index 482a9c74..d0d1313a 100644 --- a/src/repoma/check_dev_files/__init__.py +++ b/src/repoma/check_dev_files/__init__.py @@ -32,7 +32,7 @@ ) -def main(argv: Optional[Sequence[str]] = None) -> int: +def main(argv: Optional[Sequence[str]] = None) -> int: # noqa: PLR0915 parser = argparse.ArgumentParser(__doc__) parser.add_argument( "--allow-deprecated-workflows", @@ -162,7 +162,7 @@ def main(argv: Optional[Sequence[str]] = None) -> int: is_python_repo = not args.no_python if not args.repo_title: args.repo_title = args.repo_name - + has_notebooks = not args.no_notebooks executor = Executor() executor(citation.main) executor(commitlint.main) @@ -185,7 +185,7 @@ def main(argv: Optional[Sequence[str]] = None) -> int: executor(toml.main) # has to run before pre-commit executor(prettier.main, args.no_prettierrc) if is_python_repo: - executor(black.main, not args.no_notebooks) + executor(black.main, has_notebooks) executor(release_drafter.main, args.repo_name, args.repo_title) if args.pin_requirements != "no": executor( @@ -199,7 +199,7 @@ def main(argv: Optional[Sequence[str]] = None) -> int: executor(ruff.main) executor(setup_cfg.main, args.ignore_author) executor(remove_deprecated_tools, args.keep_issue_templates) - executor(vscode.main) + executor(vscode.main, has_notebooks) if not args.no_gitpod: executor(gitpod.main) executor(precommit.main) diff --git a/src/repoma/check_dev_files/vscode.py b/src/repoma/check_dev_files/vscode.py index 43786bd6..a99bf0ee 100644 --- a/src/repoma/check_dev_files/vscode.py +++ b/src/repoma/check_dev_files/vscode.py @@ -6,10 +6,10 @@ from repoma.utilities.executor import Executor -def main() -> None: +def main(has_notebooks: bool) -> None: executor = Executor() executor(_update_extensions) - executor(_update_settings) + executor(_update_settings, has_notebooks) executor.finalize() @@ -29,10 +29,12 @@ def _update_extensions() -> None: executor.finalize() -def _update_settings() -> None: +def _update_settings(has_notebooks: bool) -> None: executor = Executor() executor(_remove_outdated_settings) executor(_update_doc_settings) + if has_notebooks: + executor(_update_notebook_settings) executor(_update_pytest_settings) executor.finalize() @@ -68,6 +70,16 @@ def _update_doc_settings() -> None: executor.finalize() +def _update_notebook_settings() -> None: + """https://code.visualstudio.com/updates/v1_83#_go-to-symbol-in-notebooks.""" + if not os.path.exists("docs/"): + return + settings = { + "notebook.gotoSymbols.showAllSymbols": True, + } + vscode.set_setting(settings) + + def _update_pytest_settings() -> None: if not os.path.exists("tests/"): return