Metadata-Version: 2.4
Name: kicad-page-renumber
Version: 1.0.0
Summary: Reorder and renumber KiCad schematic sheets by hierarchy
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: pyyaml>=6.0

# kicad-page-renumber

Reorder and renumber KiCad schematic sheets by hierarchy. Point it at a
`.kicad_pro` project, arrange the sheet order, and it renumbers every page
depth-first and writes the changes back to the schematic files.

## Install

```bash
pip install kicad-page-renumber
```

Requires Python 3.10+.

## Usage

The tool operates on a KiCad project file (`.kicad_pro`).

### Interactive (default)

Launch the interactive editor, reorder sheets, then confirm to apply:

```bash
kicad-page-renumber path/to/project.kicad_pro
```

You'll see a before/after page-order diff and be prompted before anything is
written. Add `-y`/`--yes` to skip the confirmation prompt.

### Show the current hierarchy

Print the sheet hierarchy and the depth-first renumbering **without making any
changes**:

```bash
kicad-page-renumber project.kicad_pro --show
```

### Config-file workflow

Generate a YAML file describing the current order, edit it, then apply it
(no TUI):

```bash
# 1. Generate an ordering file
kicad-page-renumber project.kicad_pro --generate-config order.yaml

# 2. Edit order.yaml — reorder items within each `children` list

# 3. Apply the new ordering
kicad-page-renumber project.kicad_pro --config order.yaml
```

## Options

| Option | Description |
|--------|-------------|
| `project` | Path to the `.kicad_pro` file (required). |
| `-c`, `--config FILE` | Apply sheet order from a YAML config; skips the interactive editor. |
| `-y`, `--yes` | Skip the confirmation prompt and apply changes. |
| `--show` | Show the current hierarchy and the proposed renumbering, then exit. |
| `--generate-config OUTPUT` | Write a YAML ordering config and exit. |

## Safety

Before modifying any schematic, the tool writes a `.bak` backup of each
changed file alongside the original.
