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

Feature to disable auto-generated index.md/README.rst files #7305

Merged
merged 1 commit into from
Jul 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/guides/feature-flags.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,11 @@ By default, when Read the Docs runs Sphinx it passes a different output director
While this is a way to ensure that all the outputs are generated from scratch,
it may cause your builds to be slow if you have a big set of documentation and builds multiple formats.
In that case, enabling ``SHARE_SPHINX_DOCTREE`` could help to speed up your builds by sharing the doctree among all the formats.

``DONT_CREATE_INDEX``: :featureflags:`DONT_CREATE_INDEX`

When Read the Docs detects that your project doesn't have an ``index.md`` or ``README.rst``,
it auto-generate one for you with instructions about how to proceed.

In case you are using a static HTML page as index or an generated index from code,
this behavior could be a problem. With this feature flag you can disable that.
11 changes: 7 additions & 4 deletions readthedocs/doc_builder/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import shutil
from functools import wraps

from readthedocs.projects.models import Feature


log = logging.getLogger(__name__)

Expand Down Expand Up @@ -114,8 +116,9 @@ def create_index(self, extension='md', **__):
if os.path.exists(readme_filename):
return 'README'

index_file = open(index_filename, 'w+')
index_text = """
if not self.project.has_feature(Feature.DONT_CREATE_INDEX):
index_file = open(index_filename, 'w+')
index_text = """

Welcome to Read the Docs
------------------------
Expand All @@ -131,8 +134,8 @@ def create_index(self, extension='md', **__):
familiar with Read the Docs.
"""

index_file.write(index_text.format(dir=docs_dir, ext=extension))
index_file.close()
index_file.write(index_text.format(dir=docs_dir, ext=extension))
index_file.close()
return 'index'

def run(self, *args, **kwargs):
Expand Down
5 changes: 5 additions & 0 deletions readthedocs/projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1553,6 +1553,7 @@ def add_features(sender, **kwargs):
USE_SPHINX_RTD_EXT_LATEST = 'rtd_sphinx_ext_latest'
DEFAULT_TO_FUZZY_SEARCH = 'default_to_fuzzy_search'
INDEX_FROM_HTML_FILES = 'index_from_html_files'
DONT_CREATE_INDEX = 'dont_create_index'

FEATURES = (
(USE_SPHINX_LATEST, _('Use latest version of Sphinx')),
Expand Down Expand Up @@ -1678,6 +1679,10 @@ def add_features(sender, **kwargs):
INDEX_FROM_HTML_FILES,
_('Index content directly from html files instead or relying in other sources'),
),
(
DONT_CREATE_INDEX,
_('Do not create index.md or README.rst if the project does not have one.'),
),
)

projects = models.ManyToManyField(
Expand Down