Skip to content

Add schema for configuration file with yamale #4084

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

Merged
merged 30 commits into from
Jun 8, 2018
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.db
*.rdb
*.egg-info
*.log
*.pyc
Expand Down
96 changes: 96 additions & 0 deletions readthedocs/rtd_tests/fixtures/spec/v2/schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Read the Docs configuration file

# The version of the spec to be use
version: enum('2')
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 assume this spec will be used only on the version 2, if there is another version, we will need to create another schema.

Also, I was thinking that we can use this to validate the current v1 API. But I'm not sure if that's worth it.

Copy link
Member

Choose a reason for hiding this comment

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

Yea, I think we can keep v1 as it is.


# Formats of the documentation to be built
# Default: []
formats: any(list(enum('htmlzip', 'pdf', 'epub')), enum('all'), required=False)
Copy link
Member Author

Choose a reason for hiding this comment

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

This is only valid for sphinx, I wonder if we can move this to the sphinx key, or maybe we want to support this #1939? (still no pdf for mkdocs)

Copy link
Contributor

Choose a reason for hiding this comment

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

It's only valid for sphinx for now. We might have other engines that produce a subset of these later. I'm fine with this being top level


# Configuration for Conda support
conda: include('conda', required=False)

# Configuration for the documentation build process
build: include('build', required=False)

# Configuration of the Python environment to be used
python: include('python', required=False)

# Configuration for sphinx documentation
sphinx: include('sphinx', required=False)

# Configuration for mkdocs documentation
mkdocs: include('mkdocs', required=False)

# Submodules configuration
submodules: include('submodules', required=False)

# Redirects for the current version to be built
# Key/value list, represent redirects of type `type`
# from url -> to url
# Default: null
redirects: map(enum('page'), map(str(), str()), required=False)

---

conda:
# The path to the Conda environment file from the root of the project
environment: path()

build:
# The build docker image to be used
# Default: 'latest'
image: enum('stable', 'latest', required=False)

python:
# The Python version (this depends on the build image)
# Default: '3'
version: enum('2', '2.7', '3', '3.3', '3.4', '3.5', '3.6', required=False)

# The path to the requirements file from the root of the project
# Default: null
requirements: path(required=False)

# Install the project using python setup.py install or pip
# Default: null
install: enum('pip', 'setup.py', required=False)

# Extra requirements sections to install in addition to the package dependencies
# Default: []
extra_requirements: list(str(), required=False)

# Give the virtual environment access to the global site-packages dir
# Default: false
system_packages: bool(required=False)
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 wasn't 100% sure if this should belong in the python key

Copy link
Member

Choose a reason for hiding this comment

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

I mostly want this option to go away, but I don't know if we can do it quite yet. I think it can go in python though.


sphinx:
# The path to the conf.py file
# Default: rtd will try to find it
configuration: path(required=False)

# Add the -W option to sphinx-build
# Default: false
fail_on_warning: bool(required=False)

mkdocs:
# The path to the mkdocs.yml file
# Default: rtd will try to find it
configuration: path(required=False)

# Add the --strict optio to mkdocs build
# Default: false
fail_on_warning: bool(required=False)


submodules:
# List of submodules to be included
# Default: []
include: any(list(str()), enum('all'), required=False)

# List of submodules to be ignored
# Default: []
exclude: any(list(str()), enum('all'), required=False)
Copy link
Member

Choose a reason for hiding this comment

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

is it possible to mark these include and exclude options mutually exclusive?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nop, there isn't :/, I'll see if there is a way to implement a custom validator to do this.

Copy link
Member

Choose a reason for hiding this comment

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

I imagine we'll probably need some kind double validation:

  • First validation is whether it passes the schema
  • Second will be whether the values are actually correct in RTD (eg. a redirect with a nonsense string, or mutually exclusive options (eg. sphinx & mkdocs) and similar. Something like field-level and model-level form validation.


# Do a recursive clone?
# Default: false
recursive: bool(required=False)
Loading