-
Notifications
You must be signed in to change notification settings - Fork 9
Fix up docs #1
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
Merged
Merged
Fix up docs #1
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
From an email thread with @tdicola:
Phrases like "Get or set" and "return" are confusing because they are actions similar to how functions would be described. (Here is an example)It feels ok to say this as the implementer because you know its a function under the hood. However, from the outside, properties are more similar to variables because they represent state. Reading and writing variables is implicit in Python so its unnecessary to call it out.
You make a good point about read-only and I'd suggest using that phrase instead. So for example,
DAC value as a 16-bit unsigned value compatible with the AnalogOut class. **Read-only**
For read/write properties I think its clearer to omit it than include it. Starting a bunch of properties with the phrase "get or set" or similar is distracting.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.
Sorry I don't follow the issue with the language. This is consistent with the API docs we have today, for example DigitalInOut: http://circuitpython.readthedocs.io/en/latest/shared-bindings/digitalio/DigitalInOut.html "Get or set the pin drive mode.", "Get or set the pin pull", etc. AnalogIn: http://circuitpython.readthedocs.io/en/latest/shared-bindings/analogio/AnalogIn.html#analogio.AnalogIn.value "The returned value..." etc.
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.
Another way to say it is that attributes (whether properties, class attributes or instance attributes) don't do anything on their own so verbs like
get
,set
orreturn
are inappropriate. Instead, attributes are labels for a piece of state and Python provides separate syntax to manipulate that state. The comment should reflect what that state is not what can be done to it.We have been inconsistent about this in the past and I'd be happy to fix those places as well. MicroPython has lots of "Get or set" comments for their setter/getter functions that we have inherited.
Looking more broadly at how attributes are documented across Python packages I don't see any that say "get or set". Here is where I looked:
datetime
,subprocess
dtype
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.
Yeah this isn't actually state though, it's an I2C transaction that's reading a light level channel from the device. We might give the illusion that it's some state or attribute on an object, but it ultimately is not and can have subtle differences in behavior that need to be documented. For example these light level values are not mutable but the gain values are mutable--the documentation needs to be clear what is readable and what is writable. Removing language like "get" or "set" makes this more difficult to understand. How should a light level that can only be read be described without using the words "get" or "read", or a gain that be both written and read be described without "set", "write", or other verbs?
It's great to look at other documentation but I see plenty of things in those docs that are ambiguous here too:
Subprocess is explicit about read-write vs. read-only (popen.stdin, popen.stdout, etc.).
This could go on and on looking at different styles, etc. but isn't really productive to do so. In my mind the most important thing is consistency--if our docs today use language like "get" and "set" then I don't see why just this library needs to be the focus of a change. Let's decide on a language and make it a universal change across all the docs. I'm happy to change language but it needs to be clear what is readable and what is readable & writable state to prevent user confusion.
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.
My decision is to omit verbs from property comments because they are used and documented like attributes. I've been asking for this change on other PRs I've done in the past so some libraries are already done this way. I'm sorry I didn't provide this feedback to you sooner.
Borrowing from this style guide lets use
(read-only)
and(write-only)
at the end of property comments where they are needed. read-write properties are most common so lets omit any additional designation in that case.I'll follow up this morning with additional explanation in the design guide and fixes for the core docs you pointed out.