mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 02:34:06 -04:00
Template documentation updates
This commit is contained in:
parent
9273370150
commit
0999e9726f
@ -226,7 +226,8 @@ General Program Mode
|
|||||||
times_div_op ::= '*' | '/'
|
times_div_op ::= '*' | '/'
|
||||||
unary_op_expr ::= [ add_sub_op unary_op_expr ]* | expression
|
unary_op_expr ::= [ add_sub_op unary_op_expr ]* | expression
|
||||||
expression ::= identifier | constant | function | assignment | field_reference |
|
expression ::= identifier | constant | function | assignment | field_reference |
|
||||||
if_expression | for_expression | '(' expression_list ')'
|
if_expr | for_expr | break_expr | continue_expr |
|
||||||
|
'(' expression_list ')'
|
||||||
field_reference ::= '$' [ '$' ] [ '#' ] identifier
|
field_reference ::= '$' [ '$' ] [ '#' ] identifier
|
||||||
identifier ::= id_start [ id_rest ]*
|
identifier ::= id_start [ id_rest ]*
|
||||||
id_start ::= letter | underscore
|
id_start ::= letter | underscore
|
||||||
@ -234,13 +235,15 @@ General Program Mode
|
|||||||
constant ::= " string " | ' string ' | number
|
constant ::= " string " | ' string ' | number
|
||||||
function ::= identifier '(' expression_list [ ',' expression_list ]* ')'
|
function ::= identifier '(' expression_list [ ',' expression_list ]* ')'
|
||||||
assignment ::= identifier '=' top_expression
|
assignment ::= identifier '=' top_expression
|
||||||
if_expression ::= 'if' condition 'then' expression_list
|
if_expr ::= 'if' condition 'then' expression_list
|
||||||
[ elif_expression ] [ 'else' expression_list ] 'fi'
|
[ elif_expr ] [ 'else' expression_list ] 'fi'
|
||||||
condition ::= top_expression
|
condition ::= top_expression
|
||||||
elif_expression ::= 'elif' condition 'then' expression_list elif_expression | ''
|
elif_expr ::= 'elif' condition 'then' expression_list elif_expr | ''
|
||||||
for_expression ::= 'for' identifier 'in' list_expression
|
for_expr ::= 'for' identifier 'in' list_expr
|
||||||
[ 'separator' separator_expr ] ':' expression_list 'rof'
|
[ 'separator' separator_expr ] ':' expression_list 'rof'
|
||||||
list_expression ::= top_expression
|
list_expr ::= top_expression
|
||||||
|
break_expr ::= 'break'
|
||||||
|
continue_expr ::= 'continue'
|
||||||
separator_expr ::= top_expression
|
separator_expr ::= top_expression
|
||||||
|
|
||||||
Notes:
|
Notes:
|
||||||
@ -317,7 +320,7 @@ As a last example, this program returns the value of the ``series`` column if th
|
|||||||
|
|
||||||
**For Expressions**
|
**For Expressions**
|
||||||
|
|
||||||
The ``for`` expression iterates over a list of values, processing them one at a time. The ``list_expression`` must evaluate to either a metadata field ``lookup name``, for example ``tags`` or ``#genre``, or a list of values. If the result is a valid ``lookup name`` then the field's value is fetched and the separator specified for that field type is used. If the result isn't a valid lookup name then it is assumed to be a list of values. The list is assumed to be separated by commas unless the optional keyword ``separator`` is supplied, in which case the list values must be separated by the result of evaluating the ``separator_expr``. Each value in the list is assigned to the specified variable then the ``expression_list`` is evaluated.
|
The ``for`` expression iterates over a list of values, processing them one at a time. The ``list_expression`` must evaluate to either a metadata field ``lookup name``, for example ``tags`` or ``#genre``, or a list of values. If the result is a valid ``lookup name`` then the field's value is fetched and the separator specified for that field type is used. If the result isn't a valid lookup name then it is assumed to be a list of values. The list is assumed to be separated by commas unless the optional keyword ``separator`` is supplied, in which case the list values must be separated by the result of evaluating the ``separator_expr``. Each value in the list is assigned to the specified variable then the ``expression_list`` is evaluated. You can use ``break`` to jump out of the loop, and ``continue`` to jump to the beginning of the loop for the next iteration.
|
||||||
|
|
||||||
Example: This template removes the first hierarchical name for each value in Genre (``#genre``), constructing a list with the new names::
|
Example: This template removes the first hierarchical name for each value in Genre (``#genre``), constructing a list with the new names::
|
||||||
|
|
||||||
|
@ -75,16 +75,16 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
''')
|
''')
|
||||||
self.textBrowser.setHtml(help_text)
|
self.textBrowser.setHtml(help_text)
|
||||||
help_text = '<p>' + _('''
|
help_text = '<p>' + _('''
|
||||||
Here you can add and remove stored templates used in template processing.
|
Here you can create, edit (replace), and delete stored templates used
|
||||||
You use a stored template in another template with the '{0}' template
|
in template processing. You use a stored template in another template as
|
||||||
function, as in '{0}(some_name, arguments...)'. Stored templates must use
|
if it were a template function, for example 'some_name(arg1, arg2...)'.
|
||||||
General Program Mode -- they must begin with the text '{1}'.
|
Stored templates must use General Program Mode -- they must begin with
|
||||||
In the stored template you retrieve the arguments using the '{2}()'
|
the text '{0}'. You retrieve arguments passed to a stored template using
|
||||||
template function, as in '{2}(var1, var2, ...)'. The calling arguments
|
the '{1}()' template function, as in '{1}(var1, var2, ...)'. The passed
|
||||||
are copied to the named variables. See the template language tutorial
|
arguments are copied to the named variables. See the template language
|
||||||
for more information.
|
tutorial for more information.
|
||||||
''') + '</p>'
|
''') + '</p>'
|
||||||
self.st_textBrowser.setHtml(help_text.format('call', 'program:', 'arguments'))
|
self.st_textBrowser.setHtml(help_text.format('program:', 'arguments'))
|
||||||
self.st_textBrowser.adjustSize()
|
self.st_textBrowser.adjustSize()
|
||||||
|
|
||||||
def initialize(self):
|
def initialize(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user