Skip to content

Comments

Add comprehensive docstrings to core modules#740

Merged
jjjake merged 7 commits intomasterfrom
docstring-cleanup
Jan 30, 2026
Merged

Add comprehensive docstrings to core modules#740
jjjake merged 7 commits intomasterfrom
docstring-cleanup

Conversation

@jjjake
Copy link
Owner

@jjjake jjjake commented Jan 29, 2026

Summary

  • Add missing docstrings to core library modules for improved documentation
  • Standardize docstring format using Sphinx-style (:param:, :returns:, :raises:)
  • Convert Google-style docstrings (Args/Returns) to Sphinx-style for consistency
  • Fix pre-existing mypy type error in config.py
  • Fix docs index page issues

Changes

utils.py

  • deep_update() - Document recursive dict merging
  • validate_s3_identifier() - Document identifier validation rules
  • needs_quote() - Document URI quoting check
  • norm_filepath() - Document path normalization
  • get_md5() - Document MD5 hash calculation
  • chunk_generator() - Document file chunk generation
  • IterableToFileAdapter class - Document file-like wrapper for iterables
  • IdentifierListAsItems class - Add param documentation
  • get_s3_xml_text() - Document S3 XML error parsing
  • get_file_size() - Document file size determination
  • recursive_file_count_and_size() - Complete param documentation
  • remove_none() - Document None value removal
  • is_valid_metadata_key() - Document metadata key validation
  • parse_dict_cookies() - Document cookie string parsing
  • is_valid_email() - Document email validation
  • is_windows() - Document platform detection
  • Convert sanitize_* functions from Args/Returns to :param:/:returns:

account.py

  • Convert all methods from Google-style to Sphinx-style:
    • _post_api_request(), from_account_lookup(), _fetch_account_data_from_api()
    • from_json(), lock(), unlock(), to_dict()

api.py

  • get_tasks() - Add missing param docs (config, config_file, archive_session, etc.)
  • search_items() - Fix incorrect secure reference, add archive_session and config params
  • configure() - Add missing config_file and host param docs

session.py

  • get_connection_info() - Document return dict structure
  • rebuild_auth() - Explain redirect authentication handling
  • s3_is_overloaded() - Document S3 rate limit checking
  • get_tasks_api_rate_limit() - Document Tasks API rate limits
  • send() - Add docstring for HTTPS security handling

item.py

  • BaseItem class - Add class-level docstring
  • load(), refresh() - Document metadata loading
  • get_files() - Document file filtering options
  • Review methods (get_review, index_review, noindex_review, delete_review, review)
  • Flag methods (get_flags, add_flag, delete_flag)

config.py

  • get_auth_config() - Document authentication flow
  • write_config_file() - Document config file writing
  • parse_config_file() - Document config file search order
  • get_config() - Document config merging precedence
  • Fix mypy error: convert bool to str in config.set() call

files.py

  • BaseFile class - Add class docstring with attribute documentation

search.py

  • Search.__init__() - Document all parameters
  • iter_as_results(), iter_as_items() - Document iteration methods

iarequest.py

  • S3Request class - Document IA-S3 upload request handling
  • MetadataRequest class - Document metadata modification requests
  • prepare_patch() - Add docstring for JSON Patch creation
  • prepare_target_patch() - Add docstring for target path patching
  • prepare_files_patch() - Add docstring for file-level metadata patching
  • prepare_metadata() - Convert to Sphinx-style
  • _process_indexed_keys() - Convert to Sphinx-style

catalog.py

  • get_rate_limit() - Document rate limit checking

auth.py

  • S3Auth - Improve docstring with usage example
  • S3PostAuth - Document POST authentication scheme

docs/source/index.rst

  • Fix broken Installation link (:ref:install → `:ref:`installation)
  • Fix heading hierarchy (Setup & Configuration same level as siblings)
  • Move Authors to top-level section
  • Add Module Index to Indices and tables

docs/source/conf.py

  • Update copyright to 2015-2026

Test plan

  • All pre-commit hooks pass (ruff, black, mypy, codespell)
  • All tests pass (201 passed, 37 skipped)
  • Documentation builds successfully with cd docs && make html

🤖 Generated with Claude Code

jjjake and others added 7 commits January 29, 2026 14:07
Improve documentation coverage across the library:

- session.py: Add docstrings for get_connection_info, rebuild_auth,
  s3_is_overloaded, get_tasks_api_rate_limit
- item.py: Add docstrings for BaseItem class, load, refresh, get_files,
  review methods (get_review, index_review, noindex_review, delete_review,
  review), and flag methods (get_flags, add_flag, delete_flag)
- config.py: Add docstrings for get_auth_config, write_config_file,
  parse_config_file, get_config; fix mypy type error
- files.py: Add class docstring for BaseFile with attribute documentation
- search.py: Add docstrings for Search.__init__, iter_as_results,
  iter_as_items
- iarequest.py: Add class docstrings for S3Request and MetadataRequest
- catalog.py: Add docstring for get_rate_limit
- auth.py: Improve class docstrings for S3Auth and S3PostAuth

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Remove legacy :type: and :rtype: lines, consolidating type information
into the :param: and :returns: lines for a more concise format.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- utils.py: Add docstrings to deep_update, validate_s3_identifier,
  needs_quote, norm_filepath, get_md5, chunk_generator,
  IterableToFileAdapter, IdentifierListAsItems, get_s3_xml_text,
  get_file_size, recursive_file_count_and_size, remove_none,
  is_valid_metadata_key, parse_dict_cookies, is_valid_email, is_windows.
  Convert sanitize_* functions from Args/Returns to :param:/:returns:

- account.py: Convert all methods from Google-style (Args/Returns) to
  Sphinx-style (:param:/:returns:) for consistency

- iarequest.py: Add docstrings to prepare_patch, prepare_target_patch,
  prepare_files_patch. Convert prepare_metadata and _process_indexed_keys
  from Args/Returns to :param:/:returns:

- api.py: Add missing param docs to get_tasks, fix secure->config
  reference in search_items, add host param to configure

- session.py: Add docstring to send() method

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix broken Installation link (use :ref:`installation` not :ref:`install`)
- Fix heading hierarchy (Setup & Configuration same level as siblings)
- Move Authors to top-level section
- Add Module Index to Indices and tables
- Update copyright to 2015-2026

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
All source files now have consistent copyright: 2012-2026 Internet Archive

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
These directories are for local development:
- plans/: Local design and planning documents
- .worktrees/: Git worktrees for isolated feature development

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@jjjake jjjake merged commit 611f9cc into master Jan 30, 2026
23 checks passed
@jjjake jjjake deleted the docstring-cleanup branch February 6, 2026 20:53
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.

1 participant