-
Notifications
You must be signed in to change notification settings - Fork 110
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
ENH: Standardized way to add examples to commands #3821
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3821 +/- ##
==========================================
+ Coverage 80.74% 80.77% +0.03%
==========================================
Files 273 273
Lines 35905 35963 +58
==========================================
+ Hits 28990 29050 +60
+ Misses 6915 6913 -2
Continue to review full report at Codecov.
|
I don't think it is necessary to have the :: rst markup in commandline help
This reverts commit 843cfde.
I am not engaging, but at first look, it looks great!!! |
836639f
to
6a03cee
Compare
There is one failure not related to my changes. (due to Downloading archive: https://storage.googleapis.com/travis-ci-language-archives/python/binaries/ubuntu/16.04/x86_64/python-3.5.tar.bz2
129.62s$ curl -sSf -o python-3.5.tar.bz2 ${archive_url}
curl: (7) Failed to connect to storage.googleapis.com port 443: Connection timed out
Unable to download 3.5 archive. The archive may not exist. Please consider a different version. ) Importantly, I don't break the docs anymore by trying to improve the docs ;-) If anyone has critical feedback, I'd be very happy to hear it. |
_examples_ = [ | ||
dict(text="Drop single file content", | ||
code_py="drop('path/to/file')", | ||
code_cmd="datalad drop <path/to/file>"), |
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.
Style comment: If we are using non-placeholder syntax 'path/to/file'
for one API, we should stick with it for the other.
datalad/distribution/install.py
Outdated
"source='https://github.com/datalad-datasets/longnow-podcasts.git')", | ||
code_cmd="datalad install -d . " | ||
"--source='https://github.com/datalad-datasets/longnow-podcasts.git'"), | ||
dict(text="Install a dataset, and get all contents right away", |
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.
all content (?), i.e. no plural
I think this is great (made few comments above). I would recommend getting it merged now, and not make the conversion of all examples everywhere a precondition. In many cases those should be looked at carefully (not just converted) and re-evaluated if they still make sense at all. What I would appreciate though, is a short description of how this is meant to be in https://github.com/datalad/datalad/blob/22cef22c0f84c6a9fdd4206f94f29af8f538c670/docs/source/designpatterns.rst |
Looking forward to the ruby on rails API!
This should enable help-like specification in triple-quotes, but also meaningful formating across lines in the style of the respective API.
Removes confusing backslashes from docs too.
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 ready from my POV. Thanks!
Following up on #3757, I'm drafting a standardized way to include examples into the docstrings or help messages of commands, and I would appreciate critical feedback.
My idea was to mimick the current way in which
_params_
within each command class holds the commands parameters and has custom functions to add them to the parser or the docstring.I propose to have
_examples_
as a list of dictionaries, with each dictionary being one command example. The keytext
holds a description of the example, andcode_py
orcode_cmd
keys holds code snippets.Based on
_examples_
, additional functions inbuild_doc
andsetup_parser
build the example and append it to the docstring or the help message. This is how it currently looks for me forcmd line help
and for a
Python help
Note that in the docstrings, examples use the simple
::
rst markup which I believe gets rendered by Sphinx into code markupIf you have any thoughts on this, please let me know. I will in any case draft examples for hopefully all commands.
TODO
The dictionary data structure can be expanded with other keys, such as
setup_py
/setup_cmd
andteardown_py
/teardown_cmd
. These keys could hold the relevant code to run the command example and clean up afterwards, e.g.This would make it possible to write functions that build the examples, test whether they run, and tear down what an example executed.