Skip to content

Adding option to disable pdf/epub builds for sphinx based projects. #1344

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 11 commits into from
Jun 18, 2015
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
3 changes: 3 additions & 0 deletions readthedocs/builds/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
('html', _('HTML')),
('pdf', _('PDF')),
('epub', _('Epub')),
# There is currently no support for building man/dash formats, but we keep
# it there since the DB might still contain those values for legacy
# projects.
('man', _('Manpage')),
('dash', _('Dash')),
)
Expand Down
11 changes: 1 addition & 10 deletions readthedocs/core/management/commands/update_repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ class Command(BaseCommand):
"""

option_list = BaseCommand.option_list + (
make_option('-p',
action='store_true',
dest='pdf',
default=False,
help='Make a pdf'),
make_option('-r',
action='store_true',
dest='record',
Expand All @@ -39,7 +34,6 @@ class Command(BaseCommand):
)

def handle(self, *args, **options):
make_pdf = options['pdf']
record = options['record']
force = options['force']
version = options['version']
Expand All @@ -55,7 +49,6 @@ def handle(self, *args, **options):
active=True,
uploaded=False):
tasks.update_docs(pk=version.project_id,
pdf=make_pdf,
record=False,
version_pk=version.pk)
else:
Expand All @@ -68,14 +61,12 @@ def handle(self, *args, **options):
for version in Version.objects.filter(active=True,
uploaded=False):
tasks.update_docs(pk=version.project_id,
pdf=make_pdf,
record=record,
force=force,
version_pk=version.pk)
else:
log.info("Updating all docs")
tasks.update_docs_pull(pdf=make_pdf,
record=record,
tasks.update_docs_pull(record=record,
force=force)

@property
Expand Down
11 changes: 1 addition & 10 deletions readthedocs/core/management/commands/update_versions.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
from builds.models import Version
from django.core.management.base import BaseCommand
from optparse import make_option
from projects.tasks import update_docs


class Command(BaseCommand):
"""Custom management command to rebuild documentation for all projects on
the site. Invoked via ``./manage.py update_repos``.
"""
option_list = BaseCommand.option_list + (
make_option('-p',
action='store_true',
dest='pdf',
default=False,
help='Make a pdf'),
)

def handle(self, *args, **options):
make_pdf = options['pdf']
for version in Version.objects.filter(active=True, built=False):
update_docs(version.project_id, pdf=make_pdf, record=False,
update_docs(version.project_id, record=False,
version_pk=version.pk)
6 changes: 5 additions & 1 deletion readthedocs/doc_builder/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
mkdocs = import_module(getattr(settings, 'MKDOCS_BACKEND', 'doc_builder.backends.mkdocs'))
sphinx = import_module(getattr(settings, 'SPHINX_BACKEND', 'doc_builder.backends.sphinx'))

loading = {
BUILDER_BY_NAME = {
# Possible HTML Builders
'sphinx': sphinx.HtmlBuilder,
'sphinx_htmldir': sphinx.HtmlDirBuilder,
Expand All @@ -19,3 +19,7 @@
'mkdocs': mkdocs.MkdocsHTML,
'mkdocs_json': mkdocs.MkdocsJSON,
}


def get_builder_class(name):
return BUILDER_BY_NAME[name]
1 change: 0 additions & 1 deletion readthedocs/projects/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
('sphinx_htmldir', _('Sphinx HtmlDir')),
('sphinx_singlehtml', _('Sphinx Single Page HTML')),
#('sphinx_websupport2', _('Sphinx Websupport')),
#('sphinx_man', 'Sphinx Man'),
#('rdoc', 'Rdoc'),
)

Expand Down
2 changes: 2 additions & 0 deletions readthedocs/projects/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ class Meta:
'conf_py_file',
'default_branch',
'default_version',
'enable_pdf_build',
'enable_epub_build',
# Privacy
'privacy_level',
# 'version_privacy_level',
Expand Down
159 changes: 159 additions & 0 deletions readthedocs/projects/migrations/0045_add_format_build_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
# -*- coding: utf-8 -*-
from south.utils import datetime_utils as datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models


class Migration(SchemaMigration):

def forwards(self, orm):
# Adding field 'Project.enable_epub_build'
db.add_column(u'projects_project', 'enable_epub_build',
self.gf('django.db.models.fields.BooleanField')(default=True),
keep_default=False)

# Adding field 'Project.enable_pdf_build'
db.add_column(u'projects_project', 'enable_pdf_build',
self.gf('django.db.models.fields.BooleanField')(default=True),
keep_default=False)


def backwards(self, orm):
# Deleting field 'Project.enable_epub_build'
db.delete_column(u'projects_project', 'enable_epub_build')

# Deleting field 'Project.enable_pdf_build'
db.delete_column(u'projects_project', 'enable_pdf_build')


models = {
u'auth.group': {
'Meta': {'object_name': 'Group'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
},
u'auth.permission': {
'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'},
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
},
u'auth.user': {
'Meta': {'object_name': 'User'},
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Group']"}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Permission']"}),
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
},
u'builds.version': {
'Meta': {'ordering': "['-verbose_name']", 'unique_together': "[('project', 'slug')]", 'object_name': 'Version'},
'active': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'built': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'identifier': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'machine': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'privacy_level': ('django.db.models.fields.CharField', [], {'default': "'public'", 'max_length': '20'}),
'project': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'versions'", 'to': u"orm['projects.Project']"}),
'slug': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'supported': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'type': ('django.db.models.fields.CharField', [], {'default': "'unknown'", 'max_length': '20'}),
'uploaded': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'verbose_name': ('django.db.models.fields.CharField', [], {'max_length': '255'})
},
u'contenttypes.contenttype': {
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
},
u'projects.emailhook': {
'Meta': {'object_name': 'EmailHook'},
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'project': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'emailhook_notifications'", 'to': u"orm['projects.Project']"})
},
u'projects.importedfile': {
'Meta': {'object_name': 'ImportedFile'},
'commit': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'md5': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'path': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'project': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'imported_files'", 'to': u"orm['projects.Project']"}),
'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50'}),
'version': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'imported_files'", 'null': 'True', 'to': u"orm['builds.Version']"})
},
u'projects.project': {
'Meta': {'ordering': "('slug',)", 'object_name': 'Project'},
'allow_comments': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'analytics_code': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True', 'blank': 'True'}),
'canonical_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'}),
'comment_moderation': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'conf_py_file': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255', 'blank': 'True'}),
'copyright': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
'default_branch': ('django.db.models.fields.CharField', [], {'default': 'None', 'max_length': '255', 'null': 'True', 'blank': 'True'}),
'default_version': ('django.db.models.fields.CharField', [], {'default': "'latest'", 'max_length': '255'}),
'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'django_packages_url': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
'documentation_type': ('django.db.models.fields.CharField', [], {'default': "'auto'", 'max_length': '20'}),
'featured': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'language': ('django.db.models.fields.CharField', [], {'default': "'en'", 'max_length': '20'}),
'main_language_project': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'translations'", 'null': 'True', 'to': u"orm['projects.Project']"}),
'mirror': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'modified_date': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'num_major': ('django.db.models.fields.IntegerField', [], {'default': '2', 'max_length': '3', 'null': 'True', 'blank': 'True'}),
'num_minor': ('django.db.models.fields.IntegerField', [], {'default': '2', 'max_length': '3', 'null': 'True', 'blank': 'True'}),
'num_point': ('django.db.models.fields.IntegerField', [], {'default': '2', 'max_length': '3', 'null': 'True', 'blank': 'True'}),
'path': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'privacy_level': ('django.db.models.fields.CharField', [], {'default': "'public'", 'max_length': '20'}),
'programming_language': ('django.db.models.fields.CharField', [], {'default': "'words'", 'max_length': '20', 'blank': 'True'}),
'project_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'}),
'pub_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'python_interpreter': ('django.db.models.fields.CharField', [], {'default': "'python'", 'max_length': '20'}),
'related_projects': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': u"orm['projects.Project']", 'null': 'True', 'through': u"orm['projects.ProjectRelationship']", 'blank': 'True'}),
'repo': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'repo_type': ('django.db.models.fields.CharField', [], {'default': "'git'", 'max_length': '10'}),
'requirements_file': ('django.db.models.fields.CharField', [], {'default': 'None', 'max_length': '255', 'null': 'True', 'blank': 'True'}),
'single_version': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'skip': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '255'}),
'enable_epub_build': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'enable_pdf_build': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'suffix': ('django.db.models.fields.CharField', [], {'default': "'.rst'", 'max_length': '10'}),
'theme': ('django.db.models.fields.CharField', [], {'default': "'default'", 'max_length': '20'}),
'use_system_packages': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'use_virtualenv': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'users': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'projects'", 'symmetrical': 'False', 'to': u"orm['auth.User']"}),
'version': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
'version_privacy_level': ('django.db.models.fields.CharField', [], {'default': "'public'", 'max_length': '20'})
},
u'projects.projectrelationship': {
'Meta': {'object_name': 'ProjectRelationship'},
'child': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'superprojects'", 'to': u"orm['projects.Project']"}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'parent': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'subprojects'", 'to': u"orm['projects.Project']"})
},
u'projects.webhook': {
'Meta': {'object_name': 'WebHook'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'project': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'webhook_notifications'", 'to': u"orm['projects.Project']"}),
'url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'})
}
}

complete_apps = ['projects']
30 changes: 20 additions & 10 deletions readthedocs/projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
from vcs_support.base import VCSProject
from vcs_support.backends import backend_cls
from vcs_support.utils import Lock, NonBlockingLock
from doc_builder.loader import loading


log = logging.getLogger(__name__)
Expand Down Expand Up @@ -114,6 +113,16 @@ class Project(models.Model):
help_text=_("Google Analytics Tracking ID (ex. UA-22345342-1). "
"This may slow down your page loads."))

# Sphinx specific build options.
Copy link
Member

Choose a reason for hiding this comment

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

I think we should probably leave the "sphinx" naming off these. They should be global settings for the project, and respected where they need to be, but having "sphinx" in the name feels weird.

For example, if we ever added PDF support to other builder backends, we would use this to respect that setting, not add a 'mkdocs_enable_epub_build' option.

Copy link
Member

Choose a reason for hiding this comment

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

I'm happy to keep this PR as is, and address the naming stuff in a v2 where we move it into a completely separate model, or into a YAML file, as well, if it's a lot of work to rename all this stuff.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No it's really straightforward to rename the field again. It should be a simple search&replace. I will do so on Thursday.

enable_epub_build = models.BooleanField(
_('Enable EPUB build'), default=True,
help_text=_(
'Create a EPUB version of your documentation with each build.'))
enable_pdf_build = models.BooleanField(
_('Enable PDF build'), default=True,
help_text=_(
'Create a PDF version of your documentation with each build.'))

# Other model data.
path = models.CharField(_('Path'), max_length=255, editable=False,
help_text=_("The directory where conf.py lives"))
Expand Down Expand Up @@ -423,9 +432,6 @@ def clean_repo(self):
# Doc PATH:
# MEDIA_ROOT/slug/checkouts/version/<repo>

def doc_builder(self):
return loading.get(self.documentation_type)

@property
def doc_path(self):
return os.path.join(settings.DOCROOT, self.slug.replace('_', '-'))
Expand Down Expand Up @@ -503,18 +509,22 @@ def full_latex_path(self, version='latest'):
"""
return os.path.join(self.conf_dir(version), "_build", "latex")

def full_man_path(self, version='latest'):
"""
The path to the build man docs in the project.
"""
return os.path.join(self.conf_dir(version), "_build", "man")

def full_epub_path(self, version='latest'):
"""
The path to the build epub docs in the project.
"""
return os.path.join(self.conf_dir(version), "_build", "epub")

# There is currently no support for building man/dash formats, but we keep
# the support there for existing projects. They might have already existing
# legacy builds.

def full_man_path(self, version='latest'):
"""
The path to the build man docs in the project.
"""
return os.path.join(self.conf_dir(version), "_build", "man")

def full_dash_path(self, version='latest'):
"""
The path to the build dash docs in the project.
Expand Down
Loading