Skip to content
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

Autodoc may overwrite where functions and classes with different case exist #2024

Closed
jnothman opened this issue Sep 2, 2015 · 3 comments · Fixed by #7927
Closed

Autodoc may overwrite where functions and classes with different case exist #2024

jnothman opened this issue Sep 2, 2015 · 3 comments · Fixed by #7927

Comments

@jnothman
Copy link
Contributor

jnothman commented Sep 2, 2015

It's possible to have a function and a class in the same module whose names differ only in their case. In fact, scikit-learn includes a few:

  • sklearn.cluster.DBSCAN vs sklearn.cluster.dbscan
  • sklearn.covariance.OAS vs sklearn.covariance.OAS
  • sklearn.decomposition.FastICA vs sklearn.decomposition.fastica

Corresponding files are generated by autodoc and the handling of their different is system dependent: they may be overwritten, or may be distinguished by the OS/filesystem. Is it possible to identify such lowercase duplicates and munge the filenames to avoid conflict?

@jnothman
Copy link
Contributor Author

What would be the right way to tackle this in Sphinx? It prohibits packaging docs for Windows.

In scikit-learn's doc build, we introduced a config parameter in scikit-learn/scikit-learn#13022 which allows the doc maintainer to specify renames for paths to generated docs:

# Used by custom extension: `custom_autosummary_new_suffix` to change the
# suffix of the following functions. This works around the issue with
# `sklearn.cluster.dbscan` overlapping with `klearn.cluster.DBSCAN`  on
# case insensitive file systems.
custom_autosummary_names_with_new_suffix = {
    'sklearn.cluster.dbscan',
    'sklearn.cluster.optics',
    'sklearn.covariance.oas',
    'sklearn.decomposition.fastica'
}
custom_autosummary_new_suffix = '-lowercase.rst'
custom_autosummary_generated_dirname = os.path.join('modules', 'generated')

The implementation relied on a monkey-patch to os.path.join that would affect the behaviour of autodoc generation. We landed up having to revert it after warnings like:

WARNING: autosummary: stub file not found 'sklearn.cluster.dbscan'. Check your autosummary_generate setting. 

Where/how is the right place to implement a fix?

@tk0miya
Copy link
Member

tk0miya commented Jul 6, 2020

Here is where autosummary determines the filename of the stub files.

filename = os.path.join(path, name + suffix)

@jnothman
Copy link
Contributor Author

Hurrah! Thank you for the review!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants