Skip to content
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

Project: make description shorter #7186

Merged
merged 1 commit into from
Jun 12, 2020
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
38 changes: 0 additions & 38 deletions readthedocs/core/templatetags/core_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,44 +53,6 @@ def make_document_url(project, version=None, page='', path=''):
return resolve(project=project, version_slug=version, filename=filename)


@register.filter(is_safe=True)
def restructuredtext(value, short=False):
try:
from docutils.core import publish_parts
from docutils import ApplicationError
except ImportError:
if settings.DEBUG:
raise template.TemplateSyntaxError(
"Error in 'restructuredtext' filter: "
"The Python docutils library isn't installed.",
)
return force_text(value)
else:
docutils_settings = {
'raw_enabled': False,
'file_insertion_enabled': False,
}
docutils_settings.update(
settings.RESTRUCTUREDTEXT_FILTER_SETTINGS,
)
try:
parts = publish_parts(
source=force_bytes(value),
writer_name='html4css1',
settings_overrides=docutils_settings,
)
except ApplicationError:
return force_text(value)

out = force_text(parts['fragment'])
try:
if short:
out = out.split('\n')[0]
except IndexError:
pass
return mark_safe(out)


@register.filter
def get_project(slug):
try:
Expand Down
1 change: 1 addition & 0 deletions readthedocs/projects/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ class Meta:
description = forms.CharField(
validators=[ClassifierValidator(raises=ProjectSpamError)],
required=False,
max_length=150,
widget=forms.Textarea,
)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.12 on 2020-06-11 23:55

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('projects', '0054_urlconf_blank'),
]

operations = [
migrations.AlterField(
model_name='project',
name='description',
field=models.TextField(blank=True, help_text='Short description of this project', verbose_name='Description'),
),
]
5 changes: 1 addition & 4 deletions readthedocs/projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,7 @@ class Project(models.Model):
description = models.TextField(
_('Description'),
blank=True,
help_text=_(
'The reStructuredText '
'description of the project',
),
help_text=_('Short description of this project'),
)
repo = models.CharField(
_('Repository URL'),
Expand Down
14 changes: 0 additions & 14 deletions readthedocs/rtd_tests/tests/test_core_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,6 @@ def test_mkdocs_index_no_directory_urls(self):
url = core_tags.make_document_url(proj, LATEST, 'index', 'index.html')
self.assertEqual(url, self.pip_latest_url_index)

def test_restructured_text(self):
value = '*test*'
result = core_tags.restructuredtext(value)
self.assertIn('<em>test</em>', result)

def test_restructured_text_invalid(self):
value = (
'*******\n'
'Test\n'
'****\n\n'
)
result = core_tags.restructuredtext(value)
self.assertEqual(result, value)

def test_escapejson(self):
tests = (
({}, '{}'),
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/templates/core/project_details.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ <h3>{% trans "Build a version" %}</h3>
<div id="project_description">
<h3>{% trans "Description" %}</h3>
<p>
{{ project.description|restructuredtext }}
{{ project.description }}
</p>
</div>
{% endif %}
Expand Down