You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We currently have a lot of examples that it could be hard to know an example exists which calls a specific function of interest.
It could help a lot to add links to examples where a particular function is used. This should be automatic, as I see it in matplolib and scikit learn.
ChatGPT gave this:
importosimportglob# Enable required Sphinx extensionsextensions= [
"sphinx.ext.autodoc",
"sphinx.ext.napoleon",
"sphinx.ext.linkcode", # Enables linking to external sources
]
EXAMPLES_DIR="examples"# Path where your example scripts are storeddeffind_examples(func_name):
"""Search example scripts for function usage."""examples= []
forfileinglob.glob(os.path.join(EXAMPLES_DIR, "*.py")):
withopen(file, "r") asf:
content=f.read()
iffunc_nameincontent:
# Convert file path to a Sphinx doc referencedoc_link=f":doc:`{file.replace('.py', '')}`"examples.append(doc_link)
returnexamplesdeflink_examples(app, what, name, obj, options, lines):
"""Automatically inject example references in docstrings."""examples=find_examples(name)
ifexamples:
lines.append("\n**Examples:**")
lines.extend(["- "+eforeinexamples])
defsetup(app):
app.connect("autodoc-process-docstring", link_examples)
The text was updated successfully, but these errors were encountered:
Wonderful, it could also help to have forward references to API in examples. I think this is fairly easy, just that we should not linik it to numpy or scipy docs which will lead to a lot of confusion in links.
We currently have a lot of examples that it could be hard to know an example exists which calls a specific function of interest.
It could help a lot to add links to examples where a particular function is used. This should be automatic, as I see it in matplolib and scikit learn.
ChatGPT gave this:
The text was updated successfully, but these errors were encountered: