Skip to content

Fix use of triple backticks in docstrings - #7845

Merged
dschult merged 3 commits into
networkx:mainfrom
eriknw:fix_triple_backticks
Feb 12, 2025
Merged

dschult merged 3 commits into
networkx:mainfrom
eriknw:fix_triple_backticks

Conversation

Comment thread networkx/convert_matrix.py Outdated
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"]})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@rossbar rossbar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @eriknw !

@dschult dschult left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @eriknw!!

@dschult
dschult merged commit 0441123 into networkx:main Feb 12, 2025
@jarrodmillman jarrodmillman added this to the 3.5 milestone May 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants