Skip to content

♻️ Massive refactor / organization #840

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

Merged
merged 40 commits into from
Oct 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
f93179d
refactor!: Rename config file to workspace file
tony Oct 29, 2022
85c7412
refactor!: More renaming of config to workspace
tony Oct 29, 2022
11fc761
refactor: config_format -> workspace_file_format
tony Oct 29, 2022
4a487f9
refactor!: session_config -> workspace_dict
tony Oct 29, 2022
8d8dba6
refactor: validate_schema: windowdict -> window_dict
tony Oct 29, 2022
597e537
refactor: window_config -> window_dict
tony Oct 29, 2022
07e6a94
refactor!: sampleconfig -> sample_workspace
tony Oct 29, 2022
a5ab588
refactor(config): pane_config -> pane_dict
tony Oct 29, 2022
1b80c57
refactor: tmuxp_config -> tmuxp_workspace
tony Oct 29, 2022
7f62433
refactor(tests): config -> workspace/import
tony Oct 29, 2022
acebb1b
refactor(cli): Rename config-file -> workspace-file
tony Oct 29, 2022
2bb21df
refactor: WIP: scan_config() to config -> workspace_file, workspace_dir
tony Oct 30, 2022
05b9702
tests(cli): config_file -> workspace_file
tony Oct 30, 2022
ce01c82
test(workspace_builder): Rename config to workspace
tony Oct 30, 2022
43afa61
refactor(cli): Rename config to workspace
tony Oct 30, 2022
94f4710
refactor: VALID_WORKSPACE_DIR_FILE_EXTENSIONS
tony Oct 30, 2022
9a03520
refactor!: scan_config -> find_workspace_file
tony Oct 30, 2022
fc7cbc5
refactor(errors): ConfigError -> WorkspaceError
tony Oct 30, 2022
041a53e
validate_schema: Rename config to workspace
tony Oct 30, 2022
5aff789
refactor(config): Rename config to workspace
tony Oct 30, 2022
ae29549
refactor: Move tmuxp.config -> tmuxp.workspace.config
tony Oct 30, 2022
6dfeb38
refactor!: tmuxp.workspacebuilder -> tmuxp.workspace.builder
tony Oct 30, 2022
282fde9
refactor: Mov test_workspacebuilder.py -> workspace/test_builder.py
tony Oct 30, 2022
054683b
refactor: Move test_workspacefreezer.py -> workspace/test_freezer.py
tony Oct 30, 2022
b0b6b14
refactor: Move test_config.py -> workspace/test_config.py
tony Oct 30, 2022
0d01c81
refactor: Move test_{teamocil,tmuxinator}.py -> workspace/test_{\1}.py
tony Oct 30, 2022
a1204e0
refactor!: ConfigTestData -> WorkspaceTestData
tony Oct 30, 2022
30cb589
refactor!: Move import_{tmuxinator,teamocil} to workspace.importers
tony Oct 30, 2022
2497095
refactor!: Move workspace builder fixtures to subdirectory
tony Oct 30, 2022
b8d9c66
refactor!: Move freezing code to workspace.freezer
tony Oct 30, 2022
e740a68
test: Move inline to freezer
tony Oct 30, 2022
9403128
refactor!: get_config_dir() -> get_workspace_dir()
tony Oct 30, 2022
b3725a1
tests: Rename test find_workspace_file, note its a TODO
tony Oct 30, 2022
bb4d9ac
refactor: Move valid file extensions to workspace.constants
tony Oct 30, 2022
8da490d
Split config finding functions to workspace/finders.py
tony Oct 30, 2022
a07f82f
refactor!: Move validate_schema to workspace.validators
tony Oct 30, 2022
0d853b9
refactor(cli[load]): Language updates for config files
tony Oct 30, 2022
3110ea5
refactor(cli): Move config -> workspace renaming
tony Oct 30, 2022
2a5a1de
refactor!: Rename config to loader
tony Oct 30, 2022
1c2fe29
docs(CHANGES): Note restructuring
tony Oct 30, 2022
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
28 changes: 28 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,34 @@ $ pipx install --suffix=@next 'tmuxp' --pip-args '\--pre' --force

<!-- Maintainers, insert changes / features for the next release here -->

### Internal refactoring (#840)

#### Rename config to workspace

Reference to "config" are now "workspace"

#### Organize files

- `cli/utils.py` functions moved to `workspace/finders.py`
- `config.py` split between:

- `workspace/finders.py`
- `workspace/freezer.py`
- `workspace/importers.py`
- `workspace/validation.py`

- `workspacebuilder.py` split into:

- `workspace/builder.py`
- `workspace/freezer.py`

`config.inline` moved to freezer

#### Tests

- `tests/fixtures/{workspacebuilder,workspacefreezer}` -> `tests/fixtures/workspace/{builder,freezer}`
- `tests/test_import_{teamocil,tmuxinator}.py` -> `tests/workspace/test_import_{teamocil,tmuxinator}.py`

## tmuxp 1.17.3 (2022-10-30)

**Maintenance release, no features or fixes**
Expand Down
4 changes: 2 additions & 2 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from libtmux.test import namer
from tests.fixtures import utils as test_utils
from tmuxp.cli.utils import get_config_dir
from tmuxp.workspace.finders import get_workspace_dir

if t.TYPE_CHECKING:
from libtmux.session import Session
Expand Down Expand Up @@ -56,7 +56,7 @@ def tmuxp_configdir_default(
monkeypatch: pytest.MonkeyPatch, tmuxp_configdir: pathlib.Path
) -> None:
monkeypatch.setenv("TMUXP_CONFIGDIR", str(tmuxp_configdir))
assert get_config_dir() == str(tmuxp_configdir)
assert get_workspace_dir() == str(tmuxp_configdir)


@pytest.fixture(scope="function")
Expand Down
2 changes: 1 addition & 1 deletion docs/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ from JSON and YAML.
- `$ tmuxp -2`, `$ tmuxp -8` for forcing term colors a la
{term}`tmux(1)`.
- `$ tmuxp -L<socket-name>`, `$ tmuxp -S<socket-path>` for sockets and
`$ tmuxp -f<config-file>` for config file.
`$ tmuxp -f <workspace-file>` for config file.

[attempt at 1.7 test]: https://travis-ci.org/tmux-python/tmuxp/jobs/12348263
[mit-licensed]: http://opensource.org/licenses/MIT
Expand Down
48 changes: 27 additions & 21 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ If you need an internal API stabilized please [file an issue](https://github.com

## CLI

```{eval-rst}
.. automethod:: tmuxp.cli.utils.get_config_dir
```

```{eval-rst}
.. automethod:: tmuxp.cli.import_config.get_teamocil_dir
```
Expand All @@ -65,50 +61,54 @@ If you need an internal API stabilized please [file an issue](https://github.com
.. automethod:: tmuxp.cli.load._reattach
```

## Configuration
## Workspace files

### Finding

```{eval-rst}
.. automethod:: tmuxp.config.is_config_file
.. automethod:: tmuxp.workspace.finders.is_workspace_file
```

```{eval-rst}
.. automethod:: tmuxp.config.in_dir
.. automethod:: tmuxp.workspace.finders.in_dir
```

```{eval-rst}
.. automethod:: tmuxp.config.in_cwd
.. automethod:: tmuxp.workspace.finders.in_cwd
```

### Import and export

```{eval-rst}
.. automethod:: tmuxp.config.validate_schema
.. automethod:: tmuxp.workspace.finders.get_workspace_dir
```

### Validation

```{eval-rst}
.. automethod:: tmuxp.config.expandshell
.. autofunction:: tmuxp.workspace.validation.validate_schema
```

### Processing

```{eval-rst}
.. automethod:: tmuxp.config.expand
.. automethod:: tmuxp.workspace.loader.expandshell
```

```{eval-rst}
.. automethod:: tmuxp.config.inline
.. automethod:: tmuxp.workspace.loader.expand
```

```{eval-rst}
.. automethod:: tmuxp.config.trickle
.. automethod:: tmuxp.workspace.loader.trickle
```

## Workspace importers

```{eval-rst}
.. automethod:: tmuxp.config.import_teamocil
.. automethod:: tmuxp.workspace.importers.import_teamocil
```

```{eval-rst}
.. automethod:: tmuxp.config.import_tmuxinator
.. automethod:: tmuxp.workspace.importers.import_tmuxinator
```

## Configuration reader
Expand All @@ -120,22 +120,28 @@ If you need an internal API stabilized please [file an issue](https://github.com
## Workspace Builder

```{eval-rst}
.. autoclass:: tmuxp.workspacebuilder.WorkspaceBuilder
.. autoclass:: tmuxp.workspace.builder.WorkspaceBuilder
:members:
```

## Workspace Freezer

```{eval-rst}
.. automethod:: tmuxp.workspace.freezer.freeze
```

```{eval-rst}
.. automethod:: tmuxp.workspacebuilder.freeze
.. automethod:: tmuxp.workspace.freezer.inline
```

## Exceptions

```{eval-rst}
.. autoexception:: tmuxp.exc.EmptyConfigException
.. autoexception:: tmuxp.exc.EmptyWorkspaceException
```

```{eval-rst}
.. autoexception:: tmuxp.exc.ConfigError
.. autoexception:: tmuxp.exc.WorkspaceError
```

```{eval-rst}
Expand Down
2 changes: 1 addition & 1 deletion docs/cli/freeze.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ Tmuxp will offer to save your session state to `.json` or `.yaml`.

If no session is specified, it will default to the attached session.

If the `--force` argument is passed, it will overwrite any existing config file with the same name.
If the `--force` argument is passed, it will overwrite any existing workspace file with the same name.
4 changes: 2 additions & 2 deletions docs/cli/load.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ $ tmuxp load [filename]

## Inside sessions

If you try to load a config file from within a tmux session, it will ask you
If you try to load a workspace file from within a tmux session, it will ask you
if you want to load and attach to the new session, or just load detached.
You can also load a config file and append the windows to the current active session.
You can also load a workspace file and append the windows to the current active session.

```
Already inside TMUX, switch to session? yes/no
Expand Down
6 changes: 3 additions & 3 deletions docs/configuration/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ Edit this page.
- <https://github.com/tony/sphinxcontrib-github/blob/master/.tmuxp.yaml>

You can use `start_directory: ./` to make the directories relative to
the config file / project root.
the workspace file / project root.

## Bonus: pipenv auto-bootstrapping

Expand Down Expand Up @@ -761,8 +761,8 @@ windows:

tmuxp sessions can be scripted in python. The first way is to use the
ORM in the {ref}`API`. The second is to pass a {py:obj}`dict` into
{class}`~tmuxp.workspacebuilder.WorkspaceBuilder` with a correct schema.
See: {meth}`tmuxp.config.validate_schema`.
{class}`~tmuxp.workspace.builder.WorkspaceBuilder` with a correct schema.
See: {meth}`tmuxp.validation.validate_schema`.

:::

Expand Down
8 changes: 4 additions & 4 deletions docs/configuration/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# Configuration

tmuxp loads your terminal workspace into tmux using config files.
tmuxp loads your terminal workspace into tmux using workspace files.

The configuration file can be JSON or YAML. It's declarative style resembles tmux's object hierarchy: session, window and wanes.

Expand All @@ -24,7 +24,7 @@ tmuxp will offers to assist when:
- _When inside a tmux client_, `tmuxp` will let you create a new session and switch to it, or append the windows to your existing
session.

## What's in a config file?
## What's in a workspace file?

1. A session name
2. A list of _windows_
Expand Down Expand Up @@ -98,14 +98,14 @@ Breaking down the basic configuration into sections:
# command options
```

## Where do I store config files?
## Where do I store workspace files?

### Direct

You can create a configuration and load it from anywhere in your file system.

```console
$ tmuxp load [config_file]
$ tmuxp load [workspace-file]
```

````{tab} Relative
Expand Down
2 changes: 1 addition & 1 deletion docs/configuration/top-level.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Used for:

Notes:

- Session names may differ from config filename.
- Session names may differ from workspace filename.

e.g. _apple.yaml_:

Expand Down
12 changes: 6 additions & 6 deletions docs/developing.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,19 +159,19 @@ $ env PYTEST_ADDOPTS="-verbose" make start
Pick a file:

```console
$ env PYTEST_ADDOPTS="tests/test_workspacebuilder.py" poetry run make start
$ env PYTEST_ADDOPTS="tests/workspace/test_builder.py" poetry run make start
```

Drop into `test_automatic_rename_option()` in `tests/test_workspacebuilder.py`:
Drop into `test_automatic_rename_option()` in `tests/workspace/test_builder.py`:

```console
$ env PYTEST_ADDOPTS="-s -x -vv tests/test_workspacebuilder.py" poetry run make start
$ env PYTEST_ADDOPTS="-s -x -vv tests/workspace/test_builder.py" poetry run make start
```

Drop into `test_automatic_rename_option()` in `tests/test_workspacebuilder.py` and stop on first error:
Drop into `test_automatic_rename_option()` in `tests/workspace/test_builder.py` and stop on first error:

```console
$ env PYTEST_ADDOPTS="-s -x -vv tests/test_workspacebuilder.py::test_automatic_rename_option" poetry run make start
$ env PYTEST_ADDOPTS="-s -x -vv tests/workspace/test_builder.py::test_automatic_rename_option" poetry run make start
```

Drop into `pdb` on first error:
Expand Down Expand Up @@ -237,7 +237,7 @@ Create two terminals:
version of tmuxp above. Then:

```console
$ py.test tests/test_workspacebuilder.py
$ py.test tests/workspace/test_builder.py
```

Terminal 1 should have flickered and built the session before your eyes.
Expand Down
6 changes: 3 additions & 3 deletions examples/start-directory.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@
{
"shell_command": [
"echo '\\033c",
"./ is relative to config file location",
"../ will be parent of config file",
"./test will be \\\"test\\\" dir inside dir of config file'"
"./ is relative to workspace file location",
"../ will be parent of workspace file",
"./test will be \\\"test\\\" dir inside dir of workspace file'"
]
},
{
Expand Down
9 changes: 5 additions & 4 deletions examples/start-directory.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ windows:
panes:
- echo '\033c absolute paths also have precedence.'
- echo hello
- window_name: should be config's dir
- window_name: should be workspace file's dir

start_directory: ./
panes:
- shell_command:
- echo '\033c
- ./ is relative to config file location
- ../ will be parent of config file
- ./test will be \"test\" dir inside dir of config file'
- ./ is relative to workspace file location
- ../ will be parent of workspace file
- ./test will be \"test\" dir inside dir of workspace file'
- shell_command:
- echo '\033c
- This way you can load up workspaces from projects and maintain
Expand Down
2 changes: 1 addition & 1 deletion src/tmuxp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
:license: MIT, see LICENSE for details

"""
from . import cli, config, util
from . import cli, util
from .__about__ import (
__author__,
__copyright__,
Expand Down
Loading