Repository navigation
Fix use of triple backticks in docstrings - #7845
Conversation
| df_nodes = pd.DataFrame({"node_id": [1, 2, 3], "attribute1": ["A", "B", "C"]}) | ||
| G.add_nodes_from((n, dict(d)) for n, d in df_nodes.iterrows()) | ||
| ``` | ||
| >>> df_nodes = pd.DataFrame({"node_id": [1, 2, 3], "attribute1": ["A", "B", "C"]}) |
There was a problem hiding this comment.
Thanks for this @eriknw!
I think these triple backticks were supposed to be a sphinx way to format code without triggering a doctest.
And I suspect we didn't want to trigger a doctest because we didn't want to import pandas in a doctest here...
Anyway -- that's why these are like this. (Note the two like this are different from the other changes which were pretty clearly typos.) Not sure what is best here...
There was a problem hiding this comment.
Yeah, that intent makes sense. Let's figure out a way to render the code block correctly w/o running the code. We can use # doctest: +SKIP if necessary, but it would be nice to avoid that eyesore.
I wonder if using ``` used to work here.
There was a problem hiding this comment.
Interesting: apparently, doctests are only run when using >>>. Doing a simple indentation renders the code-block but does not execute the code. How didn't I know this? Now I'm nervous about code examples that don't use >>> 😂
See result of latest commit (a3df942) here: https://output.circle-artifacts.com/output/job/994b3d5d-0717-4af8-ac2e-e729f8519025/artifacts/0/doc/build/html/reference/generated/networkx.convert_matrix.from_pandas_edgelist.html
I noticed the docstring for
from_pandas_edgelistwas not rendering a code block correctly because it used triple backticks```, so I did a quick grep to fix their use in docstrings. See incorrect docs here: