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

Makefile: modify docstrings to use temporarily graph_objs #2406

Merged
merged 3 commits into from
Apr 29, 2020

Conversation

emmanuelle
Copy link
Contributor

This PR fixes the build of the API doc. The problem was that graph_objs objects have docstrings with intersphinx references like :class:plotly.graph_objects.scatter.Marker but (from my understanding, which might be incorrect) graph_objects are lazily imported and not found by sphinx when generating html files from the docstrings, hence no links were generated.

I solved the problem by temporarily changing the docstrings thanks to a massive sed, and reverting everything with git checkout after the sphinx build. A more robust long-term solution would be to have all the codegened code inside the graph_objects directory.

I tested that the solution works both on master and on the branch of #2403.

@nicolaskruchten @jonmmease

@nicolaskruchten
Copy link
Contributor

lol for "massive sed" :)

So the output is the same as the current output? if you do a diff on the before and after trees it's reasonable?

@emmanuelle
Copy link
Contributor Author

Hum how should I do the diff ? I cannot git diff with the version deployed on plotly.py-docs because we push -f and the histories of commits are disjoint. What I did to test was to explore the pages and follow the links, but it was indeed completely manual.

@emmanuelle
Copy link
Contributor Author

The change of this PR modifies only docstrings so not the structure of the generated html pages (but the lazy import PR might have modified this structure).

@emmanuelle
Copy link
Contributor Author

Oh wow I just saw you can do diff on linux on directories :-).

@emmanuelle
Copy link
Contributor Author

So diffing the current API doc and the one generated on master results in a lot of changes. One reason for this is that the order of objects in the _all_ of submodules has systematically changed. For example compare https://github.com/plotly/plotly.py/blob/v4.6.0/packages/python/plotly/plotly/graph_objs/bar/__init__.py#L4113 (alphabetical order from what I can see) and https://github.com/plotly/plotly.py/blob/master/packages/python/plotly/plotly/graph_objs/bar/__init__.py#L21 (inverse alphabetical order).

I can dig further but maybe @jonmmease you would know why the order has changed?

@jonmmease
Copy link
Contributor

Huh, no I don't think I had any good reason to change the sorting from alphabetical to reverse alphabetical. You could try sorting the classes and modules during code generation here:

for path_parts in datatype_rel_class_imports:
rel_classes = datatype_rel_class_imports[path_parts]
rel_modules = datatype_rel_module_imports.get(path_parts, [])

    for path_parts in datatype_rel_class_imports:
        rel_classes = sorted(datatype_rel_class_imports[path_parts])
        rel_modules = sorted(datatype_rel_module_imports.get(path_parts, []))

and see if that helps

@nicolaskruchten nicolaskruchten added this to the 4.7.0 milestone Apr 27, 2020
@emmanuelle
Copy link
Contributor Author

Thanks for the tip for the codegen @jonmmease , now the imports are indeed in alphabetical order and the API doc looks good :-). I also corrected a bug (related to graph_objects <-> graph_objs) which I had previously overlooked.

@emmanuelle
Copy link
Contributor Author

Reviewing commit by commit will be easier, the middle commit is only codegen.

@nicolaskruchten
Copy link
Contributor

Awesome! So the diff between current prod and the output of this branch is basically nil, right?

@nicolaskruchten
Copy link
Contributor

💃

@emmanuelle emmanuelle merged commit e7ad710 into master Apr 29, 2020
@nicolaskruchten nicolaskruchten deleted the links-apidoc branch June 19, 2020 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants