Skip to content

feat(pull): follow --category into subcategories with --depth - #41

Merged
CameronBrooks11 merged 1 commit into
mainfrom
feat/category-depth
Nov 13, 2026
Merged

CameronBrooks11 merged 1 commit into
mainfrom
feat/category-depth

Conversation

@CameronBrooks11

Copy link
Copy Markdown
Member

pull --depth N follows --category into subcategories, N levels down. 0, the default, keeps today's behaviour.

  • The walk is breadth first, with one visited set across all --category roots, so a subcategory reached by several paths is listed once and categories that contain each other don't loop. Water, Category:Water and category:Water are the same category.
  • --max and the language filter count the pages of the whole tree, before any page text is fetched.
  • Category pages themselves aren't pulled, as with --category today.
  • --depth below 0, or without --category, is a usage error (exit 2).
  • With --depth, stderr says how many categories were walked.
  • mw.CategoryMembers asks for gcmtype=page|subcat and returns pages and subcategory titles separately: one listing per category.

On Appropedia (./bin/wikisync pull --host www.appropedia.org --dir <scratch> --category FAST ...):

Flags Categories walked Pages
--depth 1 7 577: refused at the default --max 500, exit 1
--depth 1 --max 600 7 577 pulled
--depth 5 --max 600 12 590 pulled (the tree ends at depth 2; two subcategories are reached by two paths)

An independent walk of the same tree with a separate script gave 577 and 590.

Each new test fails when the behaviour it names is broken: walking one level too far, dropping the visited check, not normalizing category names, dropping subcategory pages, not counting the walk, not splitting or not requesting subcategories, and accepting either bad --depth.

Closes #21

pull --depth N lists a category's subcategories N levels down, breadth
first, and pulls their pages too. 0, the default, keeps the old
behaviour. A visited set lists each category once, so subcategories
reached by several paths and categories that contain each other end the
walk. --max and the language filter apply to the pages of the whole
tree, before any page text is fetched.

The listing now asks for gcmtype=page|subcat, so each category costs
one listing whatever the depth.

On Appropedia, pull --category FAST:
  --depth 1  7 categories, 577 pages (refused at the default --max 500)
  --depth 5  12 categories, 590 pages (the tree ends at depth 2)

Closes #21
@CameronBrooks11
CameronBrooks11 merged commit eb518a9 into main Nov 13, 2026
11 checks passed
@CameronBrooks11
CameronBrooks11 deleted the feat/category-depth branch November 13, 2026 01:37
CameronBrooks11 added a commit that referenced this pull request Nov 13, 2026
chore: bump version to 0.4.0

Prepares v0.4.0: the version constant becomes 0.4.0, and the
CHANGELOG's Unreleased section becomes 0.4.0. User-facing change since
v0.3.1: #41 (pull --depth follows --category into subcategories, #21).
CI action updates since then: #38, #39, #40. The tag is pushed after
this merges.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pull: follow subcategories in --category

1 participant