mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-06-21 23:19:24 -04:00
Merge branch 'wip/velsinki/formatting-improve-comments' into 'main'
Improve comment formatting and Gtk.Scale fix See merge request GNOME/blueprint-compiler!246
This commit is contained in:
commit
f8849d9084
6 changed files with 22 additions and 18 deletions
|
@ -375,7 +375,7 @@ def decompile_translatable(
|
|||
comments = ""
|
||||
else:
|
||||
comments = comments.replace("/*", " ").replace("*/", " ")
|
||||
comments = f"/* Translators: {comments} */"
|
||||
comments = f"\n/* Translators: {comments} */"
|
||||
|
||||
if context is not None:
|
||||
return comments, f"C_({escape_quote(context)}, {escape_quote(string)})"
|
||||
|
|
|
@ -179,24 +179,26 @@ def format(data, tab_size=2, insert_space=True):
|
|||
)
|
||||
|
||||
single_line_comment = str_item.startswith("//")
|
||||
if single_line_comment and not str_item.startswith("// "):
|
||||
current_line = f"// {current_line[2:]}"
|
||||
|
||||
inline_comment = not last_whitespace_contains_newline
|
||||
line_type = LineType.COMMENT
|
||||
newlines = 1
|
||||
if single_line_comment:
|
||||
if not str_item.startswith("// "):
|
||||
current_line = f"// {current_line[2:]}"
|
||||
|
||||
if not last_whitespace_contains_newline:
|
||||
current_line = " " + current_line
|
||||
newlines = 0
|
||||
elif prev_line_type == LineType.BLOCK_CLOSE:
|
||||
if inline_comment:
|
||||
current_line = " " + current_line
|
||||
line_type = prev_line_type
|
||||
newlines = 0
|
||||
elif single_line_comment:
|
||||
if prev_line_type == LineType.BLOCK_CLOSE:
|
||||
newlines = 2
|
||||
|
||||
elif prev_line_type in require_extra_newline:
|
||||
newlines = 2
|
||||
|
||||
current_line = "\n".join(
|
||||
[line.rstrip() for line in current_line.split("\n")]
|
||||
)
|
||||
commit_current_line(LineType.COMMENT, newlines_before=newlines)
|
||||
commit_current_line(line_type, newlines_before=newlines)
|
||||
|
||||
else: # pragma: no cover
|
||||
raise CompilerBugError()
|
||||
|
|
|
@ -167,8 +167,11 @@ def decompile_mark(
|
|||
comments=None,
|
||||
context=None,
|
||||
):
|
||||
comments, translatable = decompile_translatable(
|
||||
cdata, translatable, context, comments
|
||||
)
|
||||
if comments is not None:
|
||||
ctx.print(f"/* Translators: {comments} */")
|
||||
ctx.print(comments)
|
||||
|
||||
text = f"mark ({value}"
|
||||
|
||||
|
@ -177,10 +180,7 @@ def decompile_mark(
|
|||
elif cdata:
|
||||
text += f", bottom"
|
||||
|
||||
if truthy(translatable):
|
||||
comments, translatable = decompile_translatable(
|
||||
cdata, translatable, context, comments
|
||||
)
|
||||
if cdata:
|
||||
text += f", {translatable}"
|
||||
|
||||
text += "),"
|
||||
|
|
|
@ -46,7 +46,7 @@ menu menu {
|
|||
item ("test")
|
||||
|
||||
item {
|
||||
label: "test";
|
||||
label: "test"; /* Different inline comment style */
|
||||
}
|
||||
|
||||
item ("test")
|
||||
|
@ -59,7 +59,7 @@ Adw.MessageDialog {
|
|||
}
|
||||
|
||||
Adw.Breakpoint {
|
||||
condition ("width < 100")
|
||||
condition ("width < 100") // Another inline comment
|
||||
|
||||
setters {
|
||||
label2.label: _("Hello, world!");
|
||||
|
|
|
@ -4,6 +4,7 @@ Scale {
|
|||
marks [
|
||||
mark (-1, bottom),
|
||||
mark (0, top, _("Hello, world!")),
|
||||
mark (1, bottom, "1"),
|
||||
mark (2),
|
||||
]
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ corresponding .blp file and regenerate this file with blueprint-compiler.
|
|||
<marks>
|
||||
<mark value="-1" position="bottom"></mark>
|
||||
<mark value="0" position="top" translatable="yes">Hello, world!</mark>
|
||||
<mark value="1" position="bottom">1</mark>
|
||||
<mark value="2"></mark>
|
||||
</marks>
|
||||
</object>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue