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

Don't lose python/name tags values in mkdocs.yml #7507

Merged
merged 5 commits into from
Jan 19, 2021
Merged

Don't lose python/name tags values in mkdocs.yml #7507

merged 5 commits into from
Jan 19, 2021

Conversation

pawamoy
Copy link
Contributor

@pawamoy pawamoy commented Sep 24, 2020

Close #7461

@eeintech
Copy link

@pawamoy If that fix work, we owe you a beer! 🍺

@pawamoy
Copy link
Contributor Author

pawamoy commented Sep 25, 2020

I'd gladly have a beer with you @eeintech 😄 Living in Strasbourg, France by chance 😉 ?

@stsewd I can squash the commits of course, once you or someone else reviewed the PR 🙂

@eeintech
Copy link

I'd gladly have a beer with you @eeintech Living in Strasbourg, France by chance ?

Not in France at the moment, maybe one day when I visit friends in Alsace 😉

Copy link
Member

@humitos humitos left a comment

Choose a reason for hiding this comment

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

Thanks!!! Looks like a solid solution IMO. We are leaving as-is these values between load/dump conversion without touching/analyze/execute them. So, I'm 👍 and I think it's safe to merge it.

I left some comments related to the tests and some other small things, but I think we are in a good direction here.

Also, I'd super appreciate if you can create an example in our test-builds repository (https://github.com/readthedocs/test-builds) that uses MkDocs with this scenario so I can test this locally and in production in an easy way.

@stsewd what are your thoughts here?

readthedocs/config/tests/test_yaml_loader.py Outdated Show resolved Hide resolved
readthedocs/config/tests/test_yaml_loader.py Outdated Show resolved Hide resolved
readthedocs/doc_builder/backends/mkdocs.py Outdated Show resolved Hide resolved
"""

def ignore_unknown(self, node): # pylint: disable=no-self-use, unused-argument
return None

def construct_python_name(self, suffix, node): # pylint: disable=no-self-use, unused-argument
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we need the same for others like: construct_python_module, construct_python_object and maybe others here as well?

https://github.com/yaml/pyyaml/blob/538b5c93f7d5dee40322893c1e524e94a4f8bbde/lib3/yaml/constructor.py#L572

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you think we should immediately add support for all python/* tags, then yes. I only added logic for the python/name one since it's the only one I use, and the only one that is mentioned in the original issue #6889.

Just tell me and I'll update the PR to add support for the other tags!

Copy link
Member

Choose a reason for hiding this comment

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

I think it depends on if it's common to have those... But I'd say it doesn't hurt to add them now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are 16 more Python tags:

tag python
!!python/none None
!!python/bool bool
!!python/bytes (bytes in Python 3)
!!python/str str (str in Python 3)
!!python/unicode unicode (str in Python 3)
!!python/int int
!!python/long long (int in Python 3)
!!python/float float
!!python/complex complex
!!python/list list
!!python/tuple tuple
!!python/dict dict
!!python/name:module.name module.name
!!python/module:package.module package.module
!!python/object:module.cls module.cls instance
!!python/object/new:module.cls module.cls instance
!!python/object/apply:module.f value of f(...)

Taken from https://pyyaml.org/wiki/PyYAMLDocumentation#yaml-tags-and-python-types.

Honestly I'm a bit reluctant to add all these, especially at once. Some of these tags might be more complex to support (more than one suffix/value to store in a proxy object, multiple ways to write them, etc.). I think it would be best to add them one by one as people ask for them. We now know how, so it could be quick PRs.

Copy link
Member

Choose a reason for hiding this comment

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

I think it makes sense to add only what's required now to make MkDocs with plugins to work 👍

readthedocs/rtd_tests/tests/test_doc_builder.py Outdated Show resolved Hide resolved
@humitos humitos requested a review from stsewd September 28, 2020 13:32
@pawamoy
Copy link
Contributor Author

pawamoy commented Sep 28, 2020

@humitos I created a branch to add a test-build: https://github.com/pawamoy/test-builds/tree/mkdocs-python-tags, but I'm not sure how to push that branch into the main repo without merging into master.

Comment on lines +384 to +389
def yaml_dump_safely(content, stream=None):
"""Uses ``SafeDumper`` dumper to write YAML contents."""
return yaml.dump(content, stream=stream, Dumper=SafeDumper)
Copy link
Member

Choose a reason for hiding this comment

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

I think it may be good to have a test for this one as well to be sure that we are not transforming the YAML and it looks exactly the same after yaml_dump_safely, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True! I eventually added the __eq__ method to ProxyPythonName because it made the test super easy to write 🤣

def test_yaml_dump_safely():
    data = yaml_load_safely(content)
    assert yaml_load_safely(yaml_dump_safely(data)) == data

exactly the same after yaml_dump_safely

It's not the case, the indentation can change (we don't have indentation here though), and an empty string is added at the end of python/name tags (see #7461 (comment)), which is correct and expected, but different from the original input.

Copy link
Member

Choose a reason for hiding this comment

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

As far as the data is the same, I'm OK with that.

@humitos
Copy link
Member

humitos commented Sep 29, 2020

@humitos I created a branch to add a test-build: https://github.com/pawamoy/test-builds/tree/mkdocs-python-tags, but I'm not sure how to push that branch into the main repo without merging into master.

Great, thanks! I created a new branch from master with the same name you used and opened a PR to merge your branch there.

Copy link
Member

@humitos humitos left a comment

Choose a reason for hiding this comment

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

I don't know why eslint check is failing.

Other than that, I'm 👍 with these changes 💯 🎉

Thanks a lot for your PR!

@pawamoy
Copy link
Contributor Author

pawamoy commented Sep 29, 2020

I don't know why eslint check is failing.

Indeed, weird, this PR does not touch JS files 😕 Maybe there was a new release of the tool?

@stsewd
Copy link
Member

stsewd commented Sep 29, 2020

I don't know why eslint check is failing.

Indeed, weird, this PR does not touch JS files confused Maybe there was a new release of the tool?

The problem is fixed in master, you can rebase or merge master into this branch to make the tests pass

@pawamoy
Copy link
Contributor Author

pawamoy commented Sep 29, 2020

Squashed and rebased on master 🙂

@pawamoy
Copy link
Contributor Author

pawamoy commented Sep 29, 2020

Meh, build timeout 😢

@eeintech
Copy link

eeintech commented Oct 1, 2020

@humitos I'm curious to know what's the usual timing between when a PR is approved and when deployed to your build system? Really eager to be able to use this fix 😃

@humitos
Copy link
Member

humitos commented Oct 1, 2020

Around one week after it's merged

@eeintech
Copy link

eeintech commented Oct 6, 2020

@humitos And how long after PR is approved would it be merged? I see some PR from last year (2019) still not merged and it concerns me...

@pawamoy
Copy link
Contributor Author

pawamoy commented Oct 6, 2020

Oh, maybe they were waiting for me to rebase or something, I see there is a conflict. Let me do that.

@humitos
Copy link
Member

humitos commented Oct 6, 2020

Hi @eeintech! We do our best to merge and deploy PRs. Unfortunately, our time is not enough. I'm targeting this PR to be deployed next week. Let's see if we can make it happen!

@eeintech
Copy link

eeintech commented Oct 6, 2020

@humitos I understand, thanks a lot for your hard work, I hope you can make it happen too!

@stale
Copy link

stale bot commented Nov 21, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: stale Issue will be considered inactive soon label Nov 21, 2020
@pawamoy
Copy link
Contributor Author

pawamoy commented Nov 21, 2020

I'd still like to see this merged! I'll update each time the bot tries to stale it 😈

@stale stale bot removed the Status: stale Issue will be considered inactive soon label Nov 21, 2020
@stsewd
Copy link
Member

stsewd commented Nov 23, 2020

Not sure where we ended up with a decision about this. /cc @readthedocs/core

@stale
Copy link

stale bot commented Jan 17, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: stale Issue will be considered inactive soon label Jan 17, 2021
@eeintech
Copy link

@humitos Feels like this PR merge has been dragging...

@stale stale bot removed the Status: stale Issue will be considered inactive soon label Jan 17, 2021
@pawamoy
Copy link
Contributor Author

pawamoy commented Jan 17, 2021

@eeintech just keep unstaling and I'm sure good things will happen 😁

Copy link
Member

@ericholscher ericholscher left a comment

Choose a reason for hiding this comment

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

We've discussed this internally, and think this is an OK solution in the short term. In the longer term, we'd really love to not do any YAML parsing/dumping, and instead find a better way to integrate with mkdocs via an extension, or some other way that isn't so error-prone.

The main reason we are doing this currently is to add some small things to the config file. We should research and find another way of handling this, probably talking with the mkdocs team to ensure it will be supported going forward.

I'm 👍 on merging this, but we should include a # TODO: in the code linking to #7844

@stsewd stsewd merged commit f4875a2 into readthedocs:master Jan 19, 2021
@eeintech
Copy link

Yay! 👏

@steinwelberg
Copy link

I was wondering, is this change already deployed?

@stsewd
Copy link
Member

stsewd commented Feb 9, 2021

@steinwelberg no, sorry, we are going to migrate our platform to AWS, so deploys are frozen till that https://blog.readthedocs.com/aws-migration/

@steinwelberg
Copy link

steinwelberg commented Feb 9, 2021

Thanks for clarifying, and no worries, as long as it will be deployed I'm fine!

Now I come to wonder, The blog post mentions that you are migrating the community version to AWS. I am actually a business user. I guess this change is also going to be available for business users, right? I guess, that will also be done after the migration to AWS?

hehe, lots of assumptions, I hope you can clarify 😄 .

@stsewd
Copy link
Member

stsewd commented Feb 9, 2021

@steinwelberg we usually deploy both sites together, so .com deploys are frozen as well. And for clarification, .com is already on AWS, we are just going to migrate .org

@steinwelberg
Copy link

Great, I'll just have to be a bit more patient then 😉 .

@skchronicles
Copy link

skchronicles commented Feb 12, 2021

Thank you for the update @stsewd,

I am also running into the same emoji issue, and I am looking forward to the new changes. Thank you for taking the time to look into this issue 😄 and I hope your migration goes smoothly and godspeed 💯 🎉 !

@stsewd
Copy link
Member

stsewd commented Feb 16, 2021

@steinwelberg @skchronicles we just deployed the new version in .org and .com, let us know if your problems are solved now.

skchronicles added a commit to CCBR/pipeliner-docs that referenced this pull request Feb 17, 2021
@skchronicles
Copy link

@stsewd, I can confirm that the issue was fixed and that my builds are now passing 💯 🎉 💯 🎉 💯 🎉 💯 .
Thank you again! I appreciate it.

@pawamoy
Copy link
Contributor Author

pawamoy commented Feb 18, 2021

Thank you for your time dear maintainers ❤️

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.

Special !! values are reset to null in mkdocs.yml
7 participants