-
-
Notifications
You must be signed in to change notification settings - Fork 194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document the rest of the code #118
Document the rest of the code #118
Conversation
This brings GoodJob to 89% documented -- the remaining bits are the methods on `LogSubscriber`, which didn't seem worth documenting since they merely mirror the names of notifications they respond to, so I feel like they're pretty self documenting. These can probably be handled with one of: - `:nodoc:` comments (which unfortunately show up in the resulting docs) - A macro that makes a pretty simplistic comment - `@api nodoc` comments combined with `--hide-api nodoc` in the `.yardopts` file. This will hide them completely. This also adds the `yard-activesupport-concern` gem, which is pretty helpful for documenting methods inside `included` and `class_methods` blocks, which are Rails features that are wind up hiding their contents from Yard.
lib/good_job/job.rb
Outdated
# Finds the next eligible Job, acquire an advisory lock related to it, and | ||
# executes the job. | ||
# @return [Array<GoodJob::Job, Object, Exception>, nil] | ||
# If a job was executed, returns an array with the {Job} record, the | ||
# return value for the job's +#perform+ method, and the exception the job | ||
# raised, if any (if the job raised, then the second array entry will be | ||
# +nil+). If there were no jobs to execute, returns +nil+. | ||
def self.perform_with_advisory_lock |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the README and in other spots, we used the language of “executing” jobs. This made me wonder if we should have said “perform” everywhere instead. Especially since it is the ActiveJob language.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. "Perform" is the correct verb in the context of "jobs".
Unfortunately there are many things that are executed that may or may not result in a job being performed. I'm ambivalent to a search-and-replace, but a documented decision would be helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! Nothing critical needs to be changed but I left some comments for improvement.
I agree about leaving LogSubscriber undocumented.
And I understand about :nodoc:
not working, that seems to be a hill YARD wants to die on.
lib/good_job/job.rb
Outdated
# Finds the next eligible Job, acquire an advisory lock related to it, and | ||
# executes the job. | ||
# @return [Array<GoodJob::Job, Object, Exception>, nil] | ||
# If a job was executed, returns an array with the {Job} record, the | ||
# return value for the job's +#perform+ method, and the exception the job | ||
# raised, if any (if the job raised, then the second array entry will be | ||
# +nil+). If there were no jobs to execute, returns +nil+. | ||
def self.perform_with_advisory_lock |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. "Perform" is the correct verb in the context of "jobs".
Unfortunately there are many things that are executed that may or may not result in a job being performed. I'm ambivalent to a search-and-replace, but a documented decision would be helpful.
Oh, of your options for LogSubscriber, I think the macro one is best for now. |
Can do. What about the mismatch between method names and the actual notifications? e.g. |
I think they have to match or they're broken. So that might just need a todo or fixit. |
FYI, I’m rearranging some of the methods on |
Explain how it mainly relates to transactions and the visibility of new records.
I’m going to hold off on “perform” vs. “execute” in this PR since it touches a lot more files than are here, and requires some more nuance. Ready for re-review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 thank you!
This is meant to merge into #111 rather than the
main
branch.This brings GoodJob to 89% documented — the remaining bits are the methods on
LogSubscriber
, which didn't seem worth documenting since they merely mirror the names of notifications they respond to, so I feel like they're pretty self documenting. These can probably be handled with one of::nodoc:
comments (which unfortunately show up in the resulting docs).@api nodoc
comments combined with--hide-api nodoc
in the.yardopts
file. (This will hide them completely.)Additionally, I didn’t really want to mess with it too much since it looks like some of the methods are for non-existent notifications. Not sure if things have changed since you last touched it or if you were anticipating notifications that haven’t yet been created. These are all the ones that I could see GoodJob sending:
scheduler_shutdown_start
scheduler_shutdown
scheduler_restart_pools
finished_timer_task
finished_job_task
scheduler_create_pools
cleanup_preserved_jobs
enqueue_job
perform_job
notifier_listen
notifier_notified
notifier_notify_error
notifier_unlisten
Don’t know if you want to document them somewhere or not.
This also adds the
yard-activesupport-concern
gem, which is pretty helpful for documenting methods insideincluded
andclass_methods
blocks, which are Rails features that are wind up hiding their contents from Yard.I spent an unfortunate amount of time attempting to make macros work nicely for ActiveRecord’s
scope
, but never found a solution that didn’t cause strange warnings from Yard, odd behavior with duplicated methods every time you reloaded the docs, or other problems, so I wound up with pretty verbose syntax for those. There might be a nice Yard plugin that solves this better. ¯\_(ツ)_/¯Finally, I changed the CLI description setup slightly. It turns out we were putting long descriptions where the short, summary descriptions were meant to go, leaving us with this:
Now we have the more readable:
As a bonus, it let me make a nice little macro for the doc comments. 😉