Skip to content

Commit

Permalink
DX: show all symbols in Jupyter notebook (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
redeboer authored Oct 5, 2023
1 parent a52c120 commit ae838e5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/repoma/check_dev_files/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand All @@ -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(
Expand All @@ -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)
Expand Down
18 changes: 15 additions & 3 deletions src/repoma/check_dev_files/vscode.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand All @@ -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()

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ae838e5

Please sign in to comment.