readthedocs.core

readthedocs.core.admin

Django admin interface for core models

class readthedocs.core.admin.UserProjectFilter(request, params, model, model_admin)

Filter users based on project properties

queryset(request, queryset)

Add filters to queryset filter

PROJECT_ACTIVE and PROJECT_BUILT look for versions on projects, PROJECT_RECENT looks for projects with builds in the last year

readthedocs.core.forms

class readthedocs.core.forms.FacetField(choices=(), required=True, widget=None, label=None, initial=None, help_text=u'', *args, **kwargs)

For filtering searches on a facet.

Has validation for the format of facet values.

valid_value(value)

Although this is a choice field, no choices need to be supplied.

Instead, we just validate that the value is in the correct format for facet filtering (facet_name:value)

class readthedocs.core.forms.FacetedSearchForm(*args, **kwargs)

Supports fetching faceted results with a corresponding query.

facets
A list of facet names for which to get facet counts
models
Limit the search to one or more models

readthedocs.core.middleware

class readthedocs.core.middleware.FooterNoSessionMiddleware

Middleware that doesn’t create a session on logged out doc views.

This will reduce the size of our session table drastically.

class readthedocs.core.middleware.ProxyMiddleware

Middleware that sets REMOTE_ADDR based on HTTP_X_FORWARDED_FOR, if the

latter is set. This is useful if you’re sitting behind a reverse proxy that causes each request’s REMOTE_ADDR to be set to 127.0.0.1. Note that this does NOT validate HTTP_X_FORWARDED_FOR. If you’re not behind a reverse proxy that sets HTTP_X_FORWARDED_FOR automatically, do not use this middleware. Anybody can spoof the value of HTTP_X_FORWARDED_FOR, and because this sets REMOTE_ADDR based on HTTP_X_FORWARDED_FOR, that means anybody can “fake” their IP address. Only use this when you can absolutely trust the value of HTTP_X_FORWARDED_FOR.

class readthedocs.core.middleware.SingleVersionMiddleware

Reset urlconf for requests for ‘single_version’ docs.

In settings.MIDDLEWARE_CLASSES, SingleVersionMiddleware must follow after SubdomainMiddleware.

readthedocs.core.models

class readthedocs.core.models.UserProfile(*args, **kwargs)

Additional information about a User.

get_contribution_details()

Gets the line to put into commits to attribute the author.

Returns a tuple (name, email)

readthedocs.core.views

Core views, including the main homepage,

documentation and header rendering, and server errors.

readthedocs.core.views.server_error(request, exception, template_name='500.html')

A simple 500 handler so we get media

readthedocs.core.views.server_error_404(request, exception, template_name='404.html')

A simple 404 handler so we get media

readthedocs.core.management.commands

This is where custom manage.py commands are defined.

class readthedocs.core.management.commands.archive.Command(stdout=None, stderr=None, no_color=False)

Custom management command to rebuild documentation for all projects.

Invoked via ./manage.py update_repos.

class readthedocs.core.management.commands.import_github_language.Command(stdout=None, stderr=None, no_color=False)

Import a project’s programming language from GitHub.

This builds a basic management command that will set a projects language to the most used one in GitHub.

Requies a GITHUB_AUTH_TOKEN to be set in the environment, which should contain a proper GitHub Oauth Token for rate limiting.

class readthedocs.core.management.commands.update_api.Command(stdout=None, stderr=None, no_color=False)

Build documentation using the API and not hitting a database.

Usage:

./manage.py update_api <slug>
class readthedocs.core.management.commands.update_repos.Command(stdout=None, stderr=None, no_color=False)

Custom management command to rebuild documentation for all projects.

Invoked via ./manage.py update_repos.

class readthedocs.core.management.commands.update_versions.Command(stdout=None, stderr=None, no_color=False)

Custom management command to rebuild documentation for all projects.

Invoked via ./manage.py update_repos.