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
2samples/graph/steps.py
314: LARGE_ORDER = 1000.0
415: PRICE = "unit_price"
518: def totals(orders: pd.DataFrame) -> pd.DataFrame
6 variable: orders
728: def shares(orders: pd.DataFrame) -> pd.DataFrame
8 variable: orders
933: def discounts(orders: pd.DataFrame) -> pd.DataFrame
10 variable: orders
1139: def flags(orders: pd.DataFrame) -> pd.DataFrame
12 variable: orders
1347: 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
2samples/graph/impact.py
36: def totals(orders: pd.DataFrame) -> pd.DataFrame
4
5samples/graph/steps.py
618: def totals(orders: pd.DataFrame) -> pd.DataFrame
739: 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 codeMeaning
0The outline was printed
2xpd could not run, or it could not read a path