website/reference/commands/rules/outline.md
Use xpd rules outline to map what files import and define before you read them in full. It lists
definitions, imports and members with line numbers and signatures, without running any code, in
any language that ast-grep parses.
Examples
A file gets its definitions, each with the names of its members.
console
| 1 | $ xpd rules outline samples/graph/steps.py --format text |
| 2 | samples/graph/steps.py |
| 3 | 14: LARGE_ORDER = 1000.0 |
| 4 | 15: PRICE = "unit_price" |
| 5 | 18: def totals(orders: pd.DataFrame) -> pd.DataFrame |
| 6 | variable: orders |
| 7 | 28: def shares(orders: pd.DataFrame) -> pd.DataFrame |
| 8 | variable: orders |
| 9 | 33: def discounts(orders: pd.DataFrame) -> pd.DataFrame |
| 10 | variable: orders |
| 11 | 39: def flags(orders: pd.DataFrame) -> pd.DataFrame |
| 12 | variable: orders |
| 13 | 47: def features(orders: pd.DataFrame) -> pd.DataFrame |
| 14 | variable: orders |
A folder gets a shorter view, with the public names of each file grouped by kind. --type,
--match and --view narrow it down.
console
| 1 | $ xpd rules outline samples/graph --type function --match '^(totals|flags)' --view signatures --format text |
| 2 | samples/graph/impact.py |
| 3 | 6: def totals(orders: pd.DataFrame) -> pd.DataFrame |
| 4 | |
| 5 | samples/graph/steps.py |
| 6 | 18: def totals(orders: pd.DataFrame) -> pd.DataFrame |
| 7 | 39: def flags(orders: pd.DataFrame) -> pd.DataFrame |
--globs keeps or drops paths by a glob, and --follow follows symbolic links when it walks
a folder.
Exit status
| Exit code | Meaning |
|---|---|
| 0 | The outline was printed |
| 2 | xpd could not run, or it could not read a path |