reviewboard.reviews.ui.text¶
- class TextBasedReviewUI(review_request, obj)[source]¶
Bases:
FileAttachmentReviewUI
A Review UI for text-based files.
This renders the text file, applying syntax highlighting, and allows users to comment on one or more lines.
- supported_mimetypes = ['text/*', 'application/javascript', 'application/json', 'application/x-javascript', 'application/x-json', 'application/x-yaml'][source]¶
- template_name = 'reviews/ui/text.html'[source]¶
The template that renders the Review UI.
Generally, subclasses should use the default template and render the UI using JavaScript.
- source_chunk_generator_cls[source]¶
alias of
RawDiffChunkGenerator
- rendered_chunk_generator_cls[source]¶
alias of
RawDiffChunkGenerator
- js_model_class = 'RB.TextBasedReviewable'[source]¶
The name of the JavaScript model class to use for the Review UI.
- js_view_class = 'RB.TextBasedReviewableView'[source]¶
The name of the JavaScript view class to use for the Review UI.
- get_js_model_data()[source]¶
Return model data for the JavaScript AbstractReviewable subclass.
This will return information on the file attachment, its history, and any information on an attachment being diffed against.
Subclasses can override this to return additional data.
- Returns:
The attributes to pass to the model.
- Return type:
- get_extra_context(request)[source]¶
Return extra context to use when rendering the Review UI.
- Parameters:
request (
django.http.HttpRequest
) – The HTTP request from the client.- Returns:
The context to provide to the template.
- Return type:
- get_text()[source]¶
Return the file contents as a string.
This will fetch the file and then cache it for future renders.
- get_text_lines()[source]¶
Return the file contents as syntax-highlighted lines.
This will fetch the file, render it however appropriate for the review UI, and split it into reviewable lines. It will then cache it for future renders.
- get_rendered_lines()[source]¶
Returns the file contents as a render, based on the raw text.
If a subclass sets
can_render_text = True
and implementsgenerate_render
, then this will render the contents in some specialized form, cache it as a list of lines, and return it.
- generate_highlighted_text()[source]¶
Generates syntax-highlighted text for the file.
This will render the text file to HTML, applying any syntax highlighting that’s appropriate. The contents will be split into reviewable lines and will be cached for future renders.
- get_source_lexer(filename, data)[source]¶
Returns the lexer that should be used for the text.
By default, this will attempt to guess the lexer based on the filename, falling back to a plain-text lexer.
Subclasses can override this to choose a more specific lexer.
- generate_render()[source]¶
Generates a render of the text.
By default, this won’t do anything. Subclasses should override it to turn the raw text into some form of rendered content. For example, rendering Markdown.
- get_comment_thumbnail(comment)[source]¶
Generates and returns a thumbnail representing this comment.
This will find the appropriate lines the comment applies to and return it as HTML suited for rendering in reviews.
- render_comment_thumbnail(comment, begin_line_num, end_line_num, view_mode)[source]¶
Renders the content of a comment thumbnail.
This will, by default, call render() and then pull out the lines that were commented on.
Subclasses can override to do more specialized thumbnail rendering.
- get_comment_link_url(comment)[source]¶
Returns the URL to the file and line commented on.
This will link to the correct file, view mode, and line for the given comment.
- __annotations__ = {}¶