Skip to content

hooks: include private functions in export-functions.py by default; add --skip-private flag#1842

Merged
nathanjmcdougall merged 4 commits into
mainfrom
copilot/fix-export-private-functions
Apr 7, 2026
Merged

hooks: include private functions in export-functions.py by default; add --skip-private flag#1842
nathanjmcdougall merged 4 commits into
mainfrom
copilot/fix-export-private-functions

Conversation

Copilot AI commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Private helpers with docstrings were invisible to agents because export-functions.py unconditionally skipped any function starting with _. This meant reusable utilities like _get_current_python_version() were absent from docs/functions.txt and therefore from the Function Reference in AGENTS.md.

Changes

  • hooks/export-functions.py: Adds --skip-private flag (default: off). Without the flag, all functions with docstrings — public and private — are exported. --strict only enforces docstrings on public functions; private functions without docstrings are silently omitted.
  • docs/functions.txt: Regenerated — ~37 additional private helpers now included.
  • AGENTS.md: Sync block updated with the new entries.
  • src/usethis/_file/yaml/update.py: Fixed __eq__`__eq__` in docstring to prevent a prettier ↔ fix-doc-sync formatting cycle.
  • tests/hooks/test_export_functions.py: 20 new tests covering the public/private inclusion logic, --skip-private, --strict behaviour, and edge cases.

Example

# Default: export everything with a docstring
uv run hooks/export-functions.py --source-root=src/usethis --output-file=docs/functions.txt

# Old behaviour: skip private functions
uv run hooks/export-functions.py --source-root=src/usethis --output-file=docs/functions.txt --skip-private

Copilot AI and others added 3 commits April 7, 2026 06:55
… by default

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
…mitted

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix hooks export-functions.py to include private functions in docs hooks: include private functions in export-functions.py by default; add --skip-private flag Apr 7, 2026
Copilot AI requested a review from nathanjmcdougall April 7, 2026 07:08
@nathanjmcdougall nathanjmcdougall marked this pull request as ready for review April 7, 2026 07:12
@codecov

codecov Bot commented Apr 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@codspeed-hq

codspeed-hq Bot commented Apr 7, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 2 untouched benchmarks


Comparing copilot/fix-export-private-functions (e242483) with main (acd3d4e)

Open in CodSpeed

@nathanjmcdougall nathanjmcdougall merged commit cc24d55 into main Apr 7, 2026
20 checks passed
@nathanjmcdougall nathanjmcdougall deleted the copilot/fix-export-private-functions branch April 7, 2026 07:41
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.

hooks: export-functions.py excludes private functions from docs/functions.txt

2 participants