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

Force index file creation on mkdocs #3635

Closed
wants to merge 11 commits into from

Conversation

stsewd
Copy link
Member

@stsewd stsewd commented Feb 18, 2018

RTD no longer converts the README to a index file d907524, when a mkdocs project is created without one, is hard to tell why the docs aren't shown (see #1615 and #3321).

@ericholscher
Copy link
Member

ericholscher commented Feb 19, 2018

Looks like a good PR. This is something we should figure out how to test well, and include that here. I realize it might be a rabbit hole to figure out testing, but it feels hard to really do a lot of changes here without something to test it.

@stsewd
Copy link
Member Author

stsewd commented Feb 20, 2018

@ericholscher I have added some tests, not sure if they are on the correct place.

python_env = Virtualenv(version=version, build_env=build_env)
base_builder = MkdocsHTML(build_env, python_env)

def look_index_path(path):
Copy link
Member Author

Choose a reason for hiding this comment

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

I know there is a function to fake paths based on a regex, but with this form looks more explicit, at least for me.

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.

Looks great. There is some small cleanup I think, but it's good to not lie in our docs :)

return True
elif path.endswith('index.md'):
return False
return False
Copy link
Member

Choose a reason for hiding this comment

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

This is repeated 4 times, I think it should be a util method at the top of the file?

Copy link
Member Author

Choose a reason for hiding this comment

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

I will add this method to the mock path utils better :)


Welcome to Read the Docs
------------------------

This is an autogenerated index file.

Please create an ``index.{ext}`` or ``README.{ext}`` file with your own content
under the root (or ``/docs``) directory in your repository.
Please create an ``index.{ext}`` or ``README.{ext}`` (Sphinx only) file with
Copy link
Member

Choose a reason for hiding this comment

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

Why is this logic Sphinx only? Do we actually do it for Sphinx projects, but not mkdocs? Should we do it for Sphinx projects?

Copy link
Member Author

@stsewd stsewd Mar 1, 2018

Choose a reason for hiding this comment

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

I was thinking the same, I'm going to check if this works on Sphinx, if so, probably force_index would be the default behavior.

@stsewd
Copy link
Member Author

stsewd commented Mar 1, 2018

@ericholscher I take a look at the code, and notice that the template wasn't using the master_doc variable https://github.com/rtfd/readthedocs.org/blob/27d9ba3e9ab2a24f29f4b4cfead2ff32bebcaee6/readthedocs/templates/sphinx/conf.py.conf#L15

I did a test using the master_doc variable with a README.rst file and sphinx still gives 404. So should be force_index True by default? or maybe making the function always look for an index file?

Also notice that now with just a README.rst sphinx make the build to fail, since is always looking for an index.rst file.

@humitos
Copy link
Member

humitos commented Mar 7, 2018

Also notice that now with just a README.rst sphinx make the build to fail, since is always looking for an index.rst file.

I just noticed the same in locally and I wanted to report this but it seems that you already knew it. My manual test was a simple repository with just README.rst file.

@agjohnson agjohnson added this to the Mkdocs milestone Apr 10, 2018
@agjohnson agjohnson removed the Mkdocs label Apr 10, 2018
@stsewd stsewd added the Needed: design decision A core team decision is required label Apr 11, 2018
@stsewd
Copy link
Member Author

stsewd commented Apr 11, 2018

I labeling this as Needed: design decision since we need to take a decision here #3635 (comment) if always forcing the index file creation or use the master_doc variable.

@codecov
Copy link

codecov bot commented Nov 21, 2018

Codecov Report

Merging #3635 into master will increase coverage by 0.02%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #3635      +/-   ##
==========================================
+ Coverage   76.75%   76.77%   +0.02%     
==========================================
  Files         158      158              
  Lines       10048    10049       +1     
  Branches     1265     1265              
==========================================
+ Hits         7712     7715       +3     
+ Misses       1995     1994       -1     
+ Partials      341      340       -1
Impacted Files Coverage Δ
readthedocs/doc_builder/backends/mkdocs.py 90.09% <100%> (ø) ⬆️
readthedocs/doc_builder/base.py 82.6% <100%> (+3.19%) ⬆️

<https://docs.readthedocs.io/en/latest/getting_started.html>`_ to become more
familiar with Read the Docs.
"""
)
Copy link
Member Author

Choose a reason for hiding this comment

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

I also realize that this will look weird on mkdocs (because of the rst specific format used here)

@stsewd
Copy link
Member Author

stsewd commented Nov 27, 2018

I just discovered that Mkdocs already handle the case where a readme file is found, so we can't use the force_index option for mkdocs, but this PR should still be required for sphinx projects, here we want to use the force_index option.

@humitos
Copy link
Member

humitos commented Nov 18, 2019

I think we want to disable all the magic around these cases and force the user to have the same experience locally than in Read the Docs. So, if they don't have a valid index we shouldn't create one. This PR can be closed IMO.

@stsewd
Copy link
Member Author

stsewd commented Nov 18, 2019

So, if they don't have a valid index we shouldn't create one.

The thing is that users will get a 404 without any other information. In the generated index file we are showing a message that if they are seeing that page, they should create an index file.

@ericholscher
Copy link
Member

Showing a different 404 page I think makes sense. We should just fix our 404 to link to the FAQ for a couple common cases. That's a different PR though.

@stsewd
Copy link
Member Author

stsewd commented Jun 16, 2021

I think we should improve our 404 default page instead 👍

@stsewd stsewd closed this Jun 16, 2021
@stsewd stsewd deleted the force-index-file-on-mkdocs branch June 16, 2021 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needed: design decision A core team decision is required
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants