Skip to content

Commit 6f8a055

Browse files
committed
create models for mkdocs yaml
1 parent 00c5277 commit 6f8a055

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

readthedocs/builds/models.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,12 @@ def get_conf_py_path(self):
540540
conf_py_path = os.path.relpath(conf_py_path, checkout_prefix)
541541
return conf_py_path
542542

543+
def get_mkdocs_yaml_path(self):
544+
mkdocs_yml_path = self.project.yaml_dir(self.slug)
545+
checkout_prefix = self.project.checkout_path(self.slug)
546+
mkdocs_yml_path = os.path.relpath(mkdocs_yml_path, checkout_prefix)
547+
return mkdocs_yml_path
548+
543549
def get_storage_paths(self, version_slug=None):
544550
"""
545551
Return a list of all build artifact storage paths for this version.

readthedocs/projects/models.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
from readthedocs.notifications.models import Notification as NewNotification
4040
from readthedocs.projects import constants
4141
from readthedocs.projects.exceptions import ProjectConfigurationError
42+
from readthedocs.doc_builder.exceptions import MkDocsYAMLParseError
4243
from readthedocs.projects.managers import HTMLFileManager
4344
from readthedocs.projects.querysets import (
4445
ChildRelatedProjectQuerySet,
@@ -971,12 +972,31 @@ def conf_file(self, version=LATEST):
971972
)
972973

973974
raise ProjectConfigurationError(ProjectConfigurationError.NOT_FOUND)
975+
976+
977+
def yaml_file(self, version=LATEST):
978+
"""Find a mkdocs ``mkdocs.yml`` file in the project checkout."""
979+
files = self.find("mkdocs.yml", version)
980+
if not files:
981+
files = self.full_find("mkdocs.yml", version)
982+
if len(files) == 1:
983+
return files[0]
984+
## TODO Handle for multiple Files
985+
986+
raise MkDocsYAMLParseError(MkDocsYAMLParseError.NOT_FOUND)
974987

975988
def conf_dir(self, version=LATEST):
976989
conf_file = self.conf_file(version)
977990
if conf_file:
978991
return os.path.dirname(conf_file)
979992

993+
def yaml_dir(self, version=LATEST):
994+
conf_file = self.conf_file(version)
995+
if conf_file:
996+
return os.path.dirname(conf_file)
997+
998+
999+
9801000
@property
9811001
def has_good_build(self):
9821002
# Check if there is `_good_build` annotation in the Queryset.

0 commit comments

Comments
 (0)