How do I change an rst code snippet :ref:`foo` to display as Foo? - restructuredtext

An rst document has :ref:function-calls and displays it on readthedocs as function-calls, but it is the beginning of a sentence. How do I change it to display as "Function calls"?
Context: https://viper.readthedocs.io/en/latest/structure-of-a-contract.html#functions

According to the Sphinx documentation of the role :ref::
Labels that aren’t placed before a section title can still be referenced to, but you must give the link an explicit title, using this syntax:
:ref:`Link title <label-name>`
So try:
:ref:`Function calls <function-calls>`

Related

How do I make a node title translatable?

I'd like to translate each node title as a string (using i18n). I'm trying this function in my theme template:
function theme_process_page(&$variables) {
$variables['title'] = t($variables['title']);
}
Yet when I refresh strings, none of my node titles are on the list. Is there something I'm missing?
And to clarify the function name is using my theme name, not the word "theme".
Title is my usual solution for this (I use Entity Translation, it works fine with Title module).
This module replaces node titles by a regular translatable text field. You can choose wich content type titles must be replaced (on the "Manage Field" forms, you'll find a "replace" link in the title row). Pretty useful.
Good luck
You should never use t() to translate user-supplied or variable strings. See the documentation on the function.
That said, there are some solutions, one is to use the built-in language support for entity fields. Following that you should be able to do something like this in a field hook (in a module, not in your template):
$langcode = $field_info['translatable'] ? $content_langcode : LANGUAGE_NONE;
$entity->{$field_name}[$langcode][0]['value'] = t("Salut!");

Symfony2 - APYDataGridBundle - Translate title in Entity annotations

can someone give me a hint about how to set the translated title in the annotations used by the APYDataGridBundle. I have already taken a look at the documentation but the 3 lines of explanation doesn't really explain to me what I need to do to achieve the desired result.
Not as well documented as it could be, but a quick look at the twig template code, lines 68-81, reveals the exact methodology: Your translation variable is the prefixTitle of your grid object (if defined, default value is an empty string) concatenated with your specified title for the column in the annotation, so [prefixTitle][columnTitle]
You are also free to add a second translation variable called [prefixTitle][columnTitle]_abbr that just gets used in the table header, but for example in the search menu the non-abbreviated version (without _abbr suffix) gets used. This is optional.

Override only the Description field of the Plone standard content type

I would like to ovverride only the "view" of the classic "description field" of the Plone standard content type (Document, Folder, blabla), cause I need to "structure" the text of this field with structured text like:
This is my description<br/>
with many lines<br/>
bla bla<br/>
Changing the template that renders the standard description field to convert newlines to breaks isn't hard, but will require a little care to avoid creating a security hole.
Override the skin layer kss_generic_macros.pt template, either in a theming product or the custom folder.
Then, you may use Products.PythonScripts.standard.newline_to_br to convert newlines to breaks. You'll need to insert the converted text with "structure" to prevent escaping of the breaks.
Since you'll be using "structure," you absolutely must also manually html escape the description (use html_quote from standard) before applying newline_to_br, or you'll create a vector for a XSS attack.
The key section of the macro, when fixed, might read:
<div metal:define-macro="description-field-view"
id="parent-fieldname-description"
tal:define="kss_class python:getKssClasses('description',
templateId='kss_generic_macros', macro='description-field-view');
pps modules/Products.PythonScripts.standard"
tal:condition="context/Description"
tal:attributes="class string:documentDescription$kss_class;">
<span metal:define-slot="inside"
tal:replace="structure python:pps.newline_to_br(pps.html_quote(context.Description()))">Description</span>
</div>
You really don't want HTML in the description field. This field is used in a number of places and expects plain text.
You are best using the approach above to add an additional field with a different name.
If you want to customize the description widget for all content types you could create an adapter using archetypes.schemaextender (notably the ISchemaModifier interface) like this:
from my.product.browser.interfaces import IMyProductLayer
from my.product.widgets import MyCustomWidget
from Products.ATContentTypes.interface.interfaces import IATContentType
from archetypes.schemaextender.interfaces import IBrowserLayerAwareExtender
from archetypes.schemaextender.interfaces import ISchemaModifier
class MyExtender(object):
# you could choose a more specific interface for a more fine grained override
adapts(IATContentType)
implements(IBrowserLayerAwareExtender, ISchemaModifier)
# this will limit out override to this browserlayer
layer = IMyProductLayer
def fiddle(self, schema):
# if you want to customize just the template of the original widget
# see links below
schema['description'].widget=MyCustomWidget(
label='...',
....
)
return schema
and then you can register it like this:
<adapter
factory=".extender.MyExtender"
provides="archetypes.schemaextender.interfaces.ISchemaModifier" />
Don't forget to register your browser layer IMyProductLayer or this adapter will never be used.
More info:
http://pypi.python.org/pypi/archetypes.schemaextender
http://weblion.psu.edu/services/documentation/developing-for-plone/fsd-extender/hiding-fields
https://svn.plone.org/svn/archetypes/MoreFieldsAndWidgets/Products.MasterSelectWidget (a custom widget example)
http://docs.plone.org/old-reference-manuals/plone_3_theming/buildingblocks/skin/templates/customizing-at-templates/customizing-widgets.html (customize just the template of a widget)

Error: Content type X has Drupal core comment comment type, but is a comment type itself for the following content types

I'm using Node Comments module and I get a strange error in Status Report:
Node Comments
Content type Answer has Drupal core comment comment type, but is a comment type itself for the following content types: Forum topic
However, in the content type settings of 'Answer', this setting is disabled:
http://dl.dropbox.com/u/72686/CommentSettings.png
thanks
In the description under 'Node Type for Comments': "Important: Every content type which is a comment type should have itself as comment type. Also every comment node type should have at least 1 another content type using it."
What you show is the default setting. It is still possible that one of the comment nodes has a comment somewhere. You can use SQL to investigate.
To be sure that no one can create comments, you need to remove the option in the node create form. However, this wont solve the problem with the already created comment.

Insert programming code in a Lyx document

What is the best way of inserting python/C++ code in a Lyx document? The code is small examples less than 20 lines.
My Lyx document is using the Book document class.
Orjanp
I prefer to insert the listings as a child document, so the code is grabbed directly from a file that you can further edit and keep updated (you avoid to duplicate an information and maintenance is a lot easier).
To do this in Lyx:
Insert->File->Child document
Then in the window that will appear change the type to program listing and configure it as you need, for example you could want to enter the parameter language=Python (you can type a ? to view all the parameters).
A set of parameters I usually use is:
breaklines=true //--> breaks lines to margin
captionpos=b //--> caption at the bottom of the listing (default is "t")
frame=tb //--> frame at the top and at the bottom of the listing
language=Python //--> syntax highlighting for python
There should be an Insert -> Program Listing option. That uses listings Latex package, so you should have that installed. The support seems to have been added in Lyx 1.5, and from their screenshot, it seems it gives you a lot of customization options.
The insert->Program Listing feature works great. I just want to add that if you are on Mac, and try to directly paste, using command+V or right-click+paste, a block of code into the program listing, the whitespace will not be preserved, and you have to manually insert the whitespace by typing tabs, returns, etc.
A very easy way to get around this is is to paste using shift+command+V. This preserves all the whitespace of your original source code.

Resources