-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DOC: Format more code blocks #36734
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
DOC: Format more code blocks #36734
Conversation
yes you can add |
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.
lgtm
thanks @dsaxton |
'a,b,2\n' | ||
'c,d,3') | ||
|
||
data = "col1,col2,col3\na,b,1\na,b,2\nc,d,3" |
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.
IMO this is not an improvement for the specific purpuse here: reading a csv file. To visualize how the csv file looks, the way it was before is better I think. Could also use multi-line string """
, which is maybe more "black-proof"
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.
(and the same for all the ones below)
df = pd.read_csv(StringIO(data), | ||
dtype={'b': object, 'c': np.float64, 'd': 'Int64'}) | ||
df["a"][0] | ||
df = pd.read_csv(StringIO(data), dtype={"b": object, "c": np.float64, "d": "Int64"}) |
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.
Also, we should not use black's default line length limit of 88, because that will not fit in the code block width of the doc page. For example, this line is 85, and only fits exactly. So anything bigger will cause overflow/scrollbar.
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 I was wondering about this afterwards, will work on fixing these
Actually, contrary to #36700 (comment) there is quite a lot more clean up to do (so maybe could make for some good first issues @simonjayhawkins), it's just that other docs contain blocks that blacken-docs can't parse (e.g., raw output or ipython code containing magic commands). A workaround is to comment them out, parse the doc, and then uncomment (the commented blocks would then have to be edited manually).
Is it possible to render blocks like this as pure code in rst which are allowed to raise?