Skip to content

Improve and clarify doc comments for public API - #230

Merged
negasus merged 1 commit into
go-telegram:mainfrom
steindvart:Steindvart/docs-comments
Nov 24, 2026
Merged

negasus merged 1 commit into
go-telegram:mainfrom
steindvart:Steindvart/docs-comments

Conversation

@steindvart

@steindvart steindvart commented Oct 30, 2025 •

Copy link
Copy Markdown
Contributor

Problem

Closes #229

Changes

  • Clarify doc comments for bot options, handler registration, match types and ProcessUpdate based on current behavior.
  • Document the handler types added since this PR was opened.
  • Keep the existing Telegram documentation links, so each comment still opens with the symbol name.
  • Remove unused section comments in common.go and make shouldBeEscaped a constant.

@negasus negasus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for improving the documentation. The handler registration and matching descriptions are useful, but two new behavioral guarantees in options.go do not match the implementation; please address the inline comments. Please also update the branch and resolve the conflicts with the current base. For the widespread Telegram documentation-link changes, please preserve the conventional Go doc-comment opening with the documented symbol's name, rather than replacing it with a generic 'See Telegram API docs:' sentence. The link can follow that opening.

Comment thread options.go Outdated

// WithNotAsyncHandlers allows to run handlers in the main goroutine
// WithNotAsyncHandlers returns Option that runs handlers in the main goroutine.
// This ensures handlers execute sequentially instead of concurrently.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This option does not guarantee sequential execution across all updates. Start/StartWebhook launch b.workers worker goroutines, and each worker calls ProcessUpdate. WithNotAsyncHandlers runs the handler synchronously in that calling goroutine, so WithWorkers(2) can still execute two handlers concurrently. It also does not move execution to the main goroutine. Please describe this as synchronous execution in the calling goroutine (the worker for queued updates), with sequential processing per worker, rather than a global serialization guarantee.

Comment thread options.go Outdated

// WithErrorsHandler allows to set handler for errors
// WithErrorsHandler returns Option that sets handler for errors.
// This handler will be called whenever an error occurs during bot operation.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The new 'whenever an error occurs during bot operation' guarantee is too broad. Errors from explicit API calls such as SendMessage are returned to the caller through rawRequest; they are not automatically forwarded to errorsHandler. Please clarify that this callback receives errors reported internally by the library (such as polling/webhook processing errors), and that callers must still handle errors returned by API methods. Otherwise users may incorrectly rely on this callback as a catch-all error handler.

Describe bot options, handler registration and matching from their
current behavior. WithErrorsHandler receives only errors reported by the
library, and WithNotAsyncHandlers does not serialize handlers across
workers.

Keep the existing Telegram documentation links. Make shouldBeEscaped a
constant.
@steindvart
steindvart force-pushed the Steindvart/docs-comments branch from 84f2c7f to 95ae62d Compare November 24, 2026 03:29
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.69%. Comparing base (4b50daf) to head (95ae62d).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #230   +/-   ##
=======================================
  Coverage   63.69%   63.69%           
=======================================
  Files          40       40           
  Lines        3449     3449           
=======================================
  Hits         2197     2197           
- Misses       1194     1195    +1     
+ Partials       58       57    -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@steindvart

Copy link
Copy Markdown
Contributor Author

Thanks for the review. I rebuilt the branch on current main as a single commit.

  • WithNotAsyncHandlers now describes synchronous execution in the calling goroutine, with sequential processing per worker.
  • WithErrorsHandler now covers errors reported internally by the library and says that API method errors are returned to the caller.
  • The Telegram link comments are back to their existing form, so they open with the symbol name.

I also checked the other new comments against the current code and corrected a few, including WithWorkers, HandlerTypePhotoCaption and command matching. go vet ./... and go test ./... pass on Go 1.18.

@negasus negasus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for addressing the review. The worker concurrency and error-handler documentation now match the implementation. go vet ./... and go test -race ./... passed on 95ae62d.

@negasus
negasus merged commit e7e7ef6 into go-telegram:main Nov 24, 2026
3 checks passed
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.

Improve and clarify doc comments for public API

3 participants