Code

Opened 5 years ago

Closed 5 years ago

Last modified 3 years ago

#10508 closed (fixed)

Missing syntax highlighting in view code snippets in formset documentation

Reported by: Paul Menzel <paulepanter@…> Owned by: jacob
Component: Documentation Version: 1.0
Severity: Keywords: syntax error pycamp2009
Cc: humitos Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Dear developers,

there is no syntax highlighting in the first code snippet for an example view in [1].

Thanks,

Paul

[1] http://docs.djangoproject.com/en/dev/topics/forms/formsets/#using-a-formset-in-views-and-templates

Attachments (1)

10508.diff (1.2 KB) - added by mboersma 5 years ago.
Patch to turn on code highlighting for two sections in the topics/auth document

Download all attachments as: .zip

Change History (11)

comment:1 Changed 5 years ago by Paul Menzel <paulepanter@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Summary changed from Missing syntax highlighting in Using a formset in views and templates to Missing syntax highlighting in view code snippets in formset documentation

comment:2 Changed 5 years ago by Paul Menzel <paulepanter@…>

Dear developers,

I am going to just add more links to section were the code is not syntax highlighted.

Thanks,

Paul

http://docs.djangoproject.com/en/dev/topics/auth/#authentication-in-web-requests

http://docs.djangoproject.com/en/dev/topics/auth/#django.contrib.auth.login

comment:3 Changed 5 years ago by jacob

  • milestone set to 1.1
  • Triage Stage changed from Unreviewed to Accepted

comment:4 Changed 5 years ago by timo

Looks like the syntax highlighting is failing due to the if/else statements that only have comments nested in them instead of actual python code.

example:

if formset.is_valid():
  # do something with the formset.cleaned_data

Changed 5 years ago by mboersma

Patch to turn on code highlighting for two sections in the topics/auth document

comment:6 Changed 5 years ago by timo

Does the patch actually highlight the code when you build it, mboersma? I tried applying your patch and it doesn't highlight the text. Like I said before, I think this issue has to do with the syntax highlighting parser failing due to what is technically invalid python (when a comment is used to describe what to do instead of writing python statements).

comment:7 Changed 5 years ago by humitos

  • Cc humitos added
  • Keywords pycamp2009 added

I found a good description for this in http://bitbucket.org/birkenfeld/sphinx/src/bfda544c3193/doc/markup/code.rst (Line 32), it says that if the python code is invalid it will not be highlighted. So, when the code is interpret, the comments are deleted and then the code is invalid.

If you add pass below the line that contains the comment, it disappear. I can't find how to disable this option in Sphinx.

comment:8 Changed 5 years ago by jacob

  • Owner changed from nobody to jacob
  • Status changed from new to assigned

comment:9 Changed 5 years ago by jacob

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [10371]) Fixed a whole bunch of small docs typos, errors, and ommissions.

Fixes #8358, #8396, #8724, #9043, #9128, #9247, #9267, #9267, #9375, #9409, #9414, #9416, #9446, #9454, #9464, #9503, #9518, #9533, #9657, #9658, #9683, #9733, #9771, #9835, #9836, #9837, #9897, #9906, #9912, #9945, #9986, #9992, #10055, #10084, #10091, #10145, #10245, #10257, #10309, #10358, #10359, #10424, #10426, #10508, #10531, #10551, #10635, #10637, #10656, #10658, #10690, #10699, #19528.

Thanks to all the respective authors of those tickets.

comment:18 Changed 3 years ago by jacob

  • milestone 1.1 deleted

Milestone 1.1 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.