Skip to content

125 better documentation#126

Merged
ziriuz84 merged 8 commits intomainfrom
125-better-documentation
Feb 14, 2026
Merged

125 better documentation#126
ziriuz84 merged 8 commits intomainfrom
125-better-documentation

Conversation

@ziriuz84
Copy link
Owner

@ziriuz84 ziriuz84 commented Feb 14, 2026

Summary by Sourcery

Improve user- and developer-facing documentation across the project and refine configuration, interface, and scheduling utilities for a 1.0.0 release.

New Features:

  • Add get_observatory_coordinates helper to retrieve observatory metadata from the MPC database.
  • Introduce AGENTS.md with guidelines for automated agent edits in the repository.

Bug Fixes:

  • Fix twilight_sun_moon_menu to print the correct Moonset time field.
  • Replace eval-based menu input parsing in config_menu with safe integer input handling.
  • Remove leftover debug output from httpx_post requests.

Enhancements:

  • Greatly expand and clarify docstrings for interface, scheduling, configuration, and entry-point functions to describe behavior, parameters, and return values.
  • Revise README with clearer description, usage instructions, configuration details, and dependency listing.
  • Replace the ad-hoc changelog with a structured 1.0.0 changelog including categorized entries.
  • Improve Sphinx configuration to support type-hinted docs, mock heavy dependencies, set language/version metadata, and modernize intersphinx settings.
  • Refine get_observatory_coordinates to use MPC APIs with typed return values and clearer semantics.
  • Update print_obs_config to redact sensitive location information by default while allowing explicit opt-in for full output.

Documentation:

  • Document project changes for the 1.0.0 release in CHANGELOG.md.
  • Clarify internationalization, configuration, and usage details in README and Sphinx docs.
  • Add AGENTS.md to describe expectations and commands for agentic tooling.

Tests:

  • Extend configuration tests to verify redaction behavior in print_obs_config and support for showing or hiding sensitive values.

Chores:

  • Adjust Sphinx docs config and minor repo metadata for cleaner documentation generation and release preparation.

ziriuz84 and others added 8 commits December 8, 2025 23:10
This commit enhances documentation across the codebase:

- Add AGENTS.md with guidelines for AI-assisted development
  * Build, lint, and test commands
  * Code style conventions
  * Import organization and formatting rules

- Enhance module and function docstrings in Python modules:
  * Add comprehensive module-level docstring to __init__.py
  * Expand function docstrings with detailed Parameters, Returns, and Notes
  * Improve type hints and documentation in configuration.py, interface.py,
    and scheduling.py

- Improve Sphinx documentation:
  * Add introduction, features list, and quick start guide to index.rst
  * Update conf.py with better configuration
  * Enhance API reference documentation in asteroidpy.rst

All docstrings now follow NumPy-style documentation format with clear
descriptions of parameters, return values, and usage notes.
Replace eval() on user input with get_integer() to avoid code injection.
Remove the docstring Warning section that documented this risk.

Co-authored-by: Cursor <cursoragent@cursor.com>
Remove print(r.headers) from httpx_post.
Replace Italian comments in get_neocp_ephemeris with cleaner code.
Fix docstring: Form data → Query parameters for observing_target_list_scraper.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add implementation using MPC.get_observatory_location().
Derive latitude from parallax constants; return 0 for altitude (MPC
does not provide elevation). Update docstrings for load_config,
virtual_horizon_configuration, and get_observatory_coordinates.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add Parameters and Returns to setup_gettext.
Clarify select_specific_time returns naive datetime.
Improve print_change_horizon_menu and change_horizon documentation.

Co-authored-by: Cursor <cursoragent@cursor.com>
Split tests to cover both behaviors:
- test_print_obs_config_redacts_sensitive_by_default
- test_print_obs_config_shows_values_when_show_sensitive_true

Co-authored-by: Cursor <cursoragent@cursor.com>
- Add Configuration and Internationalization sections
- Update Requirements (Python 3.8+, pip)
- Improve installation with venv instructions
- Rename Library used → Dependencies, Data provenience → Data sources
- Fix typos, add release history link to CHANGELOG
- Fix Contributing section grammar

Co-authored-by: Cursor <cursoragent@cursor.com>
@ziriuz84 ziriuz84 linked an issue Feb 14, 2026 that may be closed by this pull request
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Feb 14, 2026

Reviewer's Guide

This pull request focuses on improving internal and user-facing documentation across the project, enriching docstrings for core interface, scheduling, and configuration functions, tightening Sphinx configuration for typed docs, expanding and restructuring the README and CHANGELOG, and slightly refining behavior and tests around configuration privacy and menu input safety.

Sequence diagram for safer configuration menu input handling

sequenceDiagram
    actor User
    participant MainMenu as main_menu
    participant ConfigMenu as config_menu
    participant GetInt as get_integer
    participant GeneralMenu as general_config_menu
    participant ObsMenu as observatory_config_menu

    User->>MainMenu: start application
    MainMenu->>ConfigMenu: select Configuration

    loop until choice == 0
        ConfigMenu->>GetInt: prompt "choice -> "
        GetInt-->>ConfigMenu: validated integer choice

        alt choice == 1
            ConfigMenu->>GeneralMenu: open general configuration
            GeneralMenu-->>ConfigMenu: return
        else choice == 2
            ConfigMenu->>ObsMenu: open observatory configuration
            ObsMenu-->>ConfigMenu: return
        else choice == 0
            ConfigMenu-->>MainMenu: back to main menu
        else invalid choice
            ConfigMenu-->>User: show invalid choice message
        end
    end
Loading

File-Level Changes

Change Details Files
Expanded and clarified docstrings for the interactive CLI interface and menu layer, plus safer integer input handling in the main configuration menu.
  • Added detailed parameter/return/notes sections to interface functions such as setup_gettext, input helpers, observatory/general/scheduling/main menus, and various configuration sub-menus.
  • Clarified behavior of looping input functions (get_integer/get_float) and time-selection helpers, including UTC semantics and blocking behavior.
  • Switched config_menu choice parsing from eval(input()) to the validated get_integer() helper to avoid unsafe evaluation and type errors.
asteroidpy/interface.py
Enriched scheduling utilities with precise documentation and minor robustness cleanup.
  • Documented HTTP helper functions httpx_get/httpx_post with full behavior, return types, and error-handling semantics; removed a stray debug print from httpx_post.
  • Added comprehensive docstrings to weather utilities, coordinate formatting, visibility checks, MPC scrapers, and ephemeris-related functions, including accepted inputs, units, and edge-case behavior.
  • Clarified how virtual horizon and filtering logic are applied in observing_target_list, neocp_confirmation, twilight_times, sun_moon_ephemeris, and object_ephemeris.
asteroidpy/scheduling.py
Improved configuration subsystem API documentation and introduced MPC-backed observatory coordinate lookup with better tests for privacy-aware printing.
  • Rewrote docstrings for configuration helpers (save_config, initialize, load_config, language/observatory mutators, virtual horizon configuration) to describe file locations, persistence, and failure modes.
  • Refactored get_observatory_coordinates to have a typed, documented interface, explicitly deriving latitude from MPC data and returning a structured tuple with altitude defaulting to sea level.
  • Enhanced print_obs_config to support optional redaction of sensitive observer location fields and updated tests to cover both redacted and non-redacted output paths.
asteroidpy/configuration.py
tests/test_configuration_unittest.py
tests/test_configuration.py
Modernized and expanded project-level documentation and Sphinx configuration for better typed API docs and user guidance.
  • Replaced the ad-hoc changelog section with a structured, versioned CHANGELOG including feature, bugfix, doc, test, and chore entries.
  • Substantially rewrote the README to fix wording, improve installation and usage instructions, describe configuration and i18n, and clearly list dependencies and data sources.
  • Updated Sphinx conf.py to support type-hint rendering, mock heavy runtime dependencies during doc builds, set explicit version/language, and use a mapping-based source_suffix and richer intersphinx mapping.
  • Added AGENTS.md with internal guidance for automated agent edits and clarified main() docstring in init regarding profiling behavior.
CHANGELOG.md
README.md
docs/source/conf.py
asteroidpy/__init__.py
AGENTS.md

Assessment against linked issues

Issue Objective Addressed Explanation
#125 Improve and expand in-code documentation (docstrings and comments) to follow standard conventions across the codebase.
#125 Improve and expand user-facing documentation (README, CHANGELOG, docs configuration) to be clearer, more complete, and standards-compliant.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@ziriuz84 ziriuz84 merged commit 231c0eb into main Feb 14, 2026
4 of 10 checks passed
@ziriuz84 ziriuz84 deleted the 125-better-documentation branch February 14, 2026 09:10
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 3 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `asteroidpy/scheduling.py:763-772` </location>
<code_context>

 async def get_neocp_ephemeris(
     config: ConfigParser, object_names: List[str]
-) -> Tuple[Union[Dict[str, Any], List[Dict[str, Any]], str], int]:
</code_context>

<issue_to_address>
**issue (performance):** Synchronous `requests` call inside an `async` function can block the event loop

Since this runs in an async context, the synchronous `requests.request` will block the event loop while waiting for the HTTP response. Please either switch to your existing async `httpx_get`/`httpx_post` helpers and `await` the call, or move the blocking call into a thread pool executor to avoid stalling other coroutines.
</issue_to_address>

### Comment 2
<location> `README.md:72` </location>
<code_context>
-- [7Timer](https://7timer.info)
-- [Minor Planet Center](https://www.minorplanetcenter.net/)
+- requests
+- BeautifulSoup4
+- astropy
+- astroplan
</code_context>

<issue_to_address>
**suggestion:** Use the canonical name for Beautiful Soup / beautifulsoup4 in the dependencies list.

Here it’s listed as “BeautifulSoup4”. Please use the canonical PyPI package name `beautifulsoup4` (or the official project name "Beautiful Soup 4") to match what users install.

```suggestion
- beautifulsoup4
```
</issue_to_address>

### Comment 3
<location> `docs/source/index.rst:11-12` </location>
<code_context>
+AsteroidPy is a Python tool designed to help astronomers schedule and manage
+asteroid observations and measurements. It integrates with major sources in
+minor planet research to provide accurate ephemeris predictions and NEOcp
+(Near Earth Object Confirmation Page) candidate listings.
+
+Features
</code_context>

<issue_to_address>
**suggestion (typo):** Hyphenate “Near-Earth Object” in the NEOcp expansion.

Consider updating this phrase to "Near-Earth Object Confirmation Page" to match standard terminology.

```suggestion
minor planet research to provide accurate ephemeris predictions and NEOcp
(Near-Earth Object Confirmation Page) candidate listings.
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines 763 to +772
async def get_neocp_ephemeris(
config: ConfigParser, object_names: List[str]
) -> Tuple[Union[Dict[str, Any], List[Dict[str, Any]], str], int]:
) -> Dict[str, List[str]]:
"""Retrieve ephemeris data for NEOcp objects from the Minor Planet Center.

Queries the MPC confirmation ephemeris service for multiple objects and
parses the HTML response to extract ephemeris data including velocity
and direction information.

Parameters
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (performance): Synchronous requests call inside an async function can block the event loop

Since this runs in an async context, the synchronous requests.request will block the event loop while waiting for the HTTP response. Please either switch to your existing async httpx_get/httpx_post helpers and await the call, or move the blocking call into a thread pool executor to avoid stalling other coroutines.

- [7Timer](https://7timer.info)
- [Minor Planet Center](https://www.minorplanetcenter.net/)
- requests
- BeautifulSoup4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Use the canonical name for Beautiful Soup / beautifulsoup4 in the dependencies list.

Here it’s listed as “BeautifulSoup4”. Please use the canonical PyPI package name beautifulsoup4 (or the official project name "Beautiful Soup 4") to match what users install.

Suggested change
- BeautifulSoup4
- beautifulsoup4

Comment on lines +11 to +12
minor planet research to provide accurate ephemeris predictions and NEOcp
(Near Earth Object Confirmation Page) candidate listings.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (typo): Hyphenate “Near-Earth Object” in the NEOcp expansion.

Consider updating this phrase to "Near-Earth Object Confirmation Page" to match standard terminology.

Suggested change
minor planet research to provide accurate ephemeris predictions and NEOcp
(Near Earth Object Confirmation Page) candidate listings.
minor planet research to provide accurate ephemeris predictions and NEOcp
(Near-Earth Object Confirmation Page) candidate listings.

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.

Better documentation

1 participant