How do I nest a code block in a bulleted list? - restructuredtext

I have a bulleted list that I'm trying to nest a json code block under, but this is not working:
* sldkfjlskdjflsdn
* sldkfjlskdfjlksdfj:
* my code block::
.. code-block:: json
...
"my.config": {
"sldkjflskdjfklsj": "slkdjflksdjfskdf"
},
...
This also is not working:
- sldkfjlskdjflsdn
- sldkfjlskdfjlksdfj:
- my code block
::
.. code-block:: json
...
"my.config": {
"sldkjflskdjfklsj": "slkdjflksdjfskdf"
},
...
Edit
Per the answer to this post I had a few issues with my line breaks and invalid json, etc.
Also, just want to add, my editor led me astray (not sure why snooty doesn't like it even though it builds):
So that just added to my confusion.

:: is a shortcut for .. code-block:: but uses the default language of your documentation. Do not use both. I prefer to use the latter with a language specification to be explicit.
Also you need proper indentation, white space, line feeds between nested lists, and correct syntax within your code block (do not use ... unless that is valid syntax in the language).
* sldkfjlskdjflsdn
* sldkfjlskdfjlksdfj:
* my code block:
.. code-block:: json
"my.config": {
"sldkjflskdjfklsj": "slkdjflksdjfskdf"
}

Related

google batch translate with glossary give an error

As i follow the link usingglossary and batchtranslate, and batchTranslateText api say glossaries should define like this.
glossaries:map (key: string, value: object (TranslateTextGlossaryConfig))
i want to use google batch translate with glossary,but always get errorTypeError: 'TranslateTextGlossaryConfig' object is not iterable, my glossary is Equivalent term.Can any one give me a clue? i use python as demo code here:
glossary_config = translate.TranslateTextGlossaryConfig(glossary=glossary,ignore_case=True)
glossaries=map("th",(glossary_config))
operation = client.batch_translate_text(
request={
"parent": parent,
"source_language_code": sourcefrom,
"target_language_codes": [targetto], # Up to 10 language codes here.
"input_configs": input_configs,
"output_config": output_config,
"glossaries": glossaries
}
)

Loadrunner Parameters in JSON String

I'm trying to use a parameter inside of a JSON string, and would like to use an inner parameter to replace an GUID. I've changed the default parameter start and end characters since curly braces are used in JSON.
I've tried to do something like this, where the json param contains my json which is similar to this below.
{"DashboardGUID":"<Dash_GUID>"}
request_json = lr_eval_string("<json>");
lr_save_string(request_json, "request_json_param");
I'm expecting the lr_eval_string to replace the with the GUID that's in this parameter, what's the best why of replacing this ID in my JSON String?
Not sure what you are asking but I will put this here in case someone comes here in the future:
main.c
Action()
{
lr_eval_json("Buffer/File=my_json.json", "JsonObject=MJO",LAST);
lr_json_stringify("JsonObject=MJO","Format=compact", "OutputParam=newJsonBody",LAST);
lr_save_string(lr_eval_string(lr_eval_string("{newJsonBody}")),"tmp");
web_reg_find("Text={mydate}",LAST);
web_rest("POST",
"URL=http://myServer.microfocus.com/url",
"Method=POST",
"EncType=raw",
"Body={tmp}",
HEADERS,
"Name=Content-Type", "Value=application/json", ENDHEADER,
LAST);
return 0;
}
my_json.json
{
"LastActionId": 0,
"Updated": "{mydate}"
}
Okay so instead of doing what I'm thinking above I ended up creating an array of char's with this {"DashboardGUID":"<Dash_GUID>", someotherdata:"123"} in 10 different positions within the array. I then randomly selected an element from this array and when doing the lr_eval_string the parameter was replaced.
Hopefully this makes sense those looking to do something similar.

Building of a string, which depends on variable number of parameters

My question is: how to build a string in Less, which depends on variable number of parameters. For instance, I would like to make a mixin, which helps me to write #font-face CSS rules. So I need to build src:... fonts property for arbitrary number of formats (.eot, .ttf, .oft, .woff, .woff2, .svg) of my font. Here is my Less loop to process all font formats in list:
// #some-types - it is my font formats list, just smth. like 'otf', 'eot',...
// #old-src-value - it is string with src for my font from previous loop
// #counter - it is my loop counter
.make-font-src(#some-types; #old-src-value; #counter) when (#counter <= length(#some-types)) {
// Here we get next font format from #some-types
#font-type: extract(#some-types, #counter);
// Used for building 'format("opentype")' - like part of src value string
.get-font-format(#font-type);
// Building a part of src value string for this iteration
#src-value: e('#{old-src-value}, url("#{font-path}#{font-filename}.#{font-type}") format("#{font-format}")');
// Recursive call of this mixin for looping
.make-font-src(#some-types; #src-value; (#counter + 1));
}
So I'm stuck in how to fetch complete src value string, when all font formats will be processed in the loop? Also please refer to this codepen demo.
As mentioned in my comment, this would not cause a recursive definition error because you have assigned the value to a different variable and then used it. However, it seems like Less is processing the property-value setting line as soon as the first iteration of the loop is completed. You can verify this by changing the counter value for the first iteration itself to 2 or more.
One solution (a better approach to the problem in my opinion) would be to use the property merging with comma feature and set the property-value pair directly like in the below snippet:
.make-font-src(#some-types; #counter) when (#counter <= length(#some-types)) {
#font-path: 'some/test/path/';
#font-filename: 'Arial';
#font-type: extract(#some-types, #counter);
src+: e('url("#{font-path}#{font-filename}.#{font-type}") format("#{font-type}")');
.make-font-src(#some-types; (#counter + 1));
}
div.test {
.make-font-src('eot', 'woff', 'svg'; 1);
}
This when compiled would produce the following output:
div.test {
src: url("some/test/path/Arial.eot") format("eot"),
url("some/test/path/Arial.woff") format("woff"),
url("some/test/path/Arial.svg") format("svg");
}
Finally, I found my own solution: if we add special 'getter' mixin with guard, which triggered on last iteration of the loop, we can get full src value from our loop mixin.
.getter(#cond; #list) when (#cond = length(#list)) {
#font-src-full: #src-value;
}
Here is a fiddle with demo

Gtk3 keys bindings in css files

Where can I find an exhaustive list of available keybindings that a user can define in a CSS file for GTK+ 3?
I have already checked those resources:
https://developer.gnome.org/gtk3/stable/GtkCssProvider.html
https://developer.gnome.org/gtk3/stable/gtk3-Bindings.html
/usr/share/themes/Default/gtk-3.0/gtk-keys.css (which is empty)
/usr/share/themes/Emacs/gtk-3.0/gtk-keys.css
For example, how can a user make <Control>Space move the cursor to the end of the text in a GtkTextView?
It seems that there is no exhaustive documentation. Here is what I have found so far:
The list of the possible actions (from /usr/share/themes/Emacs/gtk-3.0/gtk-keys.css) :
move-cursor
delete-from-cursor
cut-clipboard
past-clipboard
start-interactive-search
move-current
Get the gtk+ code :
git clone git://git.gnome.org/gtk+
For example, the "move-cursor action":
bind "<ctrl>b" { "move-cursor" (logical-positions, -1, 0) };
If you do a :
grep -i logical gtk+/gtk/gtkenums.h
You will find a match and see that there are others possibilities :
/**
* GtkMovementStep:
* #GTK_MOVEMENT_LOGICAL_POSITIONS: Move forward or back by graphemes
* #GTK_MOVEMENT_VISUAL_POSITIONS: Move left or right by graphemes
* #GTK_MOVEMENT_WORDS: Move forward or back by words
* #GTK_MOVEMENT_DISPLAY_LINES: Move up or down lines (wrapped lines)
* #GTK_MOVEMENT_DISPLAY_LINE_ENDS: Move to either end of a line
* #GTK_MOVEMENT_PARAGRAPHS: Move up or down paragraphs (newline-ended lines)
* #GTK_MOVEMENT_PARAGRAPH_ENDS: Move to either end of a paragraph
* #GTK_MOVEMENT_PAGES: Move by pages
* #GTK_MOVEMENT_BUFFER_ENDS: Move to ends of the buffer
* #GTK_MOVEMENT_HORIZONTAL_PAGES: Move horizontally by pages
*/
For example the binding I wanted to do (move the cursor to the end of the text in a Gtk::TextView)
bind "<Control>KP_Space" { "move-cursor" (buffer-ends, 1, 0) }
The "template" is :
bind "key_combination" { "action" (action_param1, action_param2, ...)}
For the move-cursor action, the parameters are (step, count, extend_selection), where step is one of the above enum values. To note that for line-ends, paragraph-ends and buffer-ends a negative count means "beginning" and a positive value means "end". And extend_selection is simply 0 or 1 (for C-style "False" and "True").
In the same way, the options for the action "delete-from-cursor" are :
/**
* GtkDeleteType:
* #GTK_DELETE_CHARS: Delete characters.
* #GTK_DELETE_WORD_ENDS: Delete only the portion of the word to the
* left/right of cursor if we’re in the middle of a word.
* #GTK_DELETE_WORDS: Delete words.
* #GTK_DELETE_DISPLAY_LINES: Delete display-lines. Display-lines
* refers to the visible lines, with respect to to the current line
* breaks. As opposed to paragraphs, which are defined by line
* breaks in the input.
* #GTK_DELETE_DISPLAY_LINE_ENDS: Delete only the portion of the
* display-line to the left/right of cursor.
* #GTK_DELETE_PARAGRAPH_ENDS: Delete to the end of the
* paragraph. Like C-k in Emacs (or its reverse).
* #GTK_DELETE_PARAGRAPHS: Delete entire line. Like C-k in pico.
* #GTK_DELETE_WHITESPACE: Delete only whitespace. Like M-\ in Emacs.
*
* See also: #GtkEntry::delete-from-cursor.
*/
Now if you want all to see all the possible actions that are hard coded, then
here is a way :
find ./gtk+/ -type f | xargs grep -A 2 gtk_binding_entry_add_signal
You will see lot of things like this :
./gtk+/gtk/gtklabel.c: gtk_binding_entry_add_signal (binding_set, GDK_KEY_backslash, GDK_CONTROL_MASK,
./gtk+/gtk/gtklabel.c- "move-cursor", 3,
./gtk+/gtk/gtklabel.c- G_TYPE_ENUM, GTK_MOVEMENT_PARAGRAPH_ENDS,
--
./gtk+/gtk/gtklabel.c: gtk_binding_entry_add_signal (binding_set, GDK_KEY_c, GDK_CONTROL_MASK,
./gtk+/gtk/gtklabel.c- "copy-clipboard", 0);
./gtk+/gtk/gtklabel.c-
./gtk+/gtk/gtklabel.c: gtk_binding_entry_add_signal (binding_set, GDK_KEY_Return, 0,
./gtk+/gtk/gtklabel.c- "activate-current-link", 0);
./gtk+/gtk/gtklabel.c: gtk_binding_entry_add_signal (binding_set, GDK_KEY_ISO_Enter, 0,
./gtk+/gtk/gtklabel.c- "activate-current-link", 0);
./gtk+/gtk/gtklabel.c: gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Enter, 0,
./gtk+/gtk/gtklabel.c- "activate-current-link", 0);
./gtk+/gtk/gtklabel.c-
--
./gtk+/gtk/gtkdialog.c: gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0, "close", 0);
Then it should be easy to find what you were looking for.
My guess is you should find any signal with the G_SIGNAL_ACTION flag enabled. You could get this list programmatically from the Gtk gir file (/usr/share/gir-1.0/Gtk-3.0.gir on my system) by looking for every <glib:signal> entity with the action attribute set to 1.
I am not so fond on XPath to come out with a one-line solution though.
I've also been looking for proper documentation of possible key bindings for quite a while now and just stumbled over these docs of the single-line text widget GtkEntry. In this particular case, one can scroll all the way down to the end of the menu to find all other "keybinding signals" the widget offers, like insert_at_cursor, paste_clipboard etc. including the parameters these signals accept (such as the DeleteType in case of delete_from_cursor). It now shouldn't be too hard to find the signals for other GTK widgets.
Update: If the Vala docs provide a detailed description of the keybinding signals, one might assume that the regular Gtk3 docs do, too. Indeed. It's always easier to find what you're looking for if you know what you're looking for. :)
I think ultimately ntd has the most correct idea, but here is a more browsable solution, rather than grepping through the GIR file.
You should (assuming comprehensive documentation) be able to find this info by going to the documentation page for the widget of interest, then search that page for the term keybinding signal.
The available signals are documented along with the others on each widget's page and then qualified as whether or not they are for key bindings in the description.
Usually you can also identify them by the fact that their value in the 2nd column of the summary table of signals, i.e. signal type flags, is Action, as also pointed out by ntd.
For example, GtkComboBox:move-active:
[handler function signature]
The ::move-active signal is a keybinding signal which gets emitted to move the active selection.
[description of arguments]
As ntd indicated, this can probably be automated to a large extent. Like the GIR, the documentation is generated from the C source files, so if you lack a GIR file or just prefer this way, you can presumably do some clever use of grep, sed, et al. through those to pull out the info.
#ntd suggested looking at /usr/share/gir-1.0/Gtk-3.0.gir for
<glib:signal action="1"> entities. I don't have a Gtk-3.0.gir but I do have a Gtk-2.0.gir and these are the unique results I found using that approach:
cat /usr/share/gir-1.0/Gtk-2.0.gir \
| sed -n '/.*<glib:signal name="\([^"]*\)".* action="1".*/s//\1/p' \
| sort -u
abort-column-resize
accept-position
activate
activate-current
activate-cursor-item
activate-default
activate-focus
backspace
cancel
cancel-position
change-current-page
change-focus-row-expansion
change-value
clicked
close
composited-changed
copy-clipboard
cut-clipboard
cycle-focus
delete-from-cursor
end-selection
expand-collapse-cursor-row
extend-selection
focus-home-or-end
focus-tab
grab-focus
insert-at-cursor
kill-char
kill-line
kill-word
move
move-active
move-current
move-cursor
move-focus
move-focus-out
move-handle
move-page
move-scroll
move-slider
move-to-column
move-to-row
move-viewport
move-word
page-horizontally
paste-clipboard
popdown
popup
popup-menu
reorder-tab
row-activated
scroll-child
scroll-horizontal
scroll-vertical
select-all
select-cursor-item
select-cursor-parent
select-cursor-row
select-page
set-anchor
set-editable
set-scroll-adjustments
show-help
start-interactive-search
start-selection
toggle-add-mode
toggle-cursor-item
toggle-cursor-row
toggle-cursor-visible
toggle-focus-row
toggle-overwrite
undo-selection
unselect-all

Code Conventions / coding rules of a language

I would like to define a set of coding rules of a language structural proprietary language,
how can I proceed?
thank you very much
Some of your rules will be easy to deal with using only parsing. For example to find the number of lines in a function is not hard:
void function() : {
int firstLine, lastLine ; }
{
{firstLine = getToken(1).beginLine ; }
...
{lastLine = getToken(0).beginLine ; }
{check( lastLine - firstLine + 1 <= 150 ) ; }
}
Other rules, such as your example of nested ifs, will be best handled by traversing an abstract syntax tree. I'd suggest you look into JJTree. It supports visitors, which could be quite useful for encoding some of your rules.
If I have understood correctly,
in the file .jj, I have to add this function , which allows to check how many line of code in a method
or in the file parseur.java generated by javacc.

Resources