readthedocs.core
¶
readthedocs.core.admin
¶
Django admin interface for core models
-
class
readthedocs.core.admin.
UserAdminExtra
(model, admin_site)¶ Admin configuration for User.
-
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
andPROJECT_BUILT
look for versions on projects,PROJECT_RECENT
looks for projects with builds in the last year
-
readthedocs.core.forms
¶
Forms for core app.
-
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
¶
Middleware for core app.
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.
-
class
readthedocs.core.middleware.
SubdomainMiddleware
¶ Middleware to display docs for non-dashboard domains
-
process_request
(request)¶ Process requests for unhandled domains
If the request is not for our
PUBLIC_DOMAIN
, or ifPUBLIC_DOMAIN
is not set and the request is for a subdomain onPRODUCTION_DOMAIN
, process the request as a request a documentation project.
-
readthedocs.core.models
¶
Models for the core app.
readthedocs.core.views
¶
Core views, including the main homepage,
documentation and header rendering, and server errors.
-
readthedocs.core.views.
server_error_404
(request, exception, template_name='404.html')¶ A simple 404 handler so we get media
-
readthedocs.core.views.
server_error_500
(request, exception, template_name='500.html')¶ A simple 500 handler so we get media
readthedocs.core.management.commands
¶
This is where custom manage.py
commands are defined.
Rebuild documentation for all projects
Clean up stable build paths per project version
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.
Requires a GITHUB_AUTH_TOKEN
to be set in the environment,
which should contain a proper GitHub Oauth Token for rate limiting.
Resync GitHub project for user
Trigger build for project slug
Reindex Elastic Search indexes
Generate metadata for all projects
Update symlinks for projects
Build documentation using the API and not hitting a database.
Usage:
./manage.py update_api <slug>
Custom management command to rebuild documentation for all projects.
Invoked via ./manage.py update_repos
.
-
class
readthedocs.core.management.commands.update_repos.
Command
(stdout=None, stderr=None, no_color=False)¶ Management command for rebuilding documentation on projects
Rebuild documentation for all projects