Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Unified Diff: tools/json_schema_compiler/idl_schema.py

Issue 404203002: Extension docs: Make comments in IDL files generate paragraphs rather than (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase, bump yaml files Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/json_schema_compiler/dart_test/comments.idl ('k') | tools/json_schema_compiler/idl_schema_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/json_schema_compiler/idl_schema.py
diff --git a/tools/json_schema_compiler/idl_schema.py b/tools/json_schema_compiler/idl_schema.py
index 2b8a4992ec9c706e5bdf24629e43e8ba49653ad7..a9137569cc348f0583110e279e9a523b016c7543 100644
--- a/tools/json_schema_compiler/idl_schema.py
+++ b/tools/json_schema_compiler/idl_schema.py
@@ -56,19 +56,20 @@ def ProcessComment(comment):
}
)
'''
+ def add_paragraphs(content):
+ paragraphs = content.split('\n\n')
+ if len(paragraphs) < 2:
+ return content
+ return '<p>' + '</p><p>'.join(p.strip() for p in paragraphs) + '</p>'
+
# Find all the parameter comments of the form '|name|: comment'.
parameter_starts = list(re.finditer(r' *\|([^|]*)\| *: *', comment))
# Get the parent comment (everything before the first parameter comment.
first_parameter_location = (parameter_starts[0].start()
if parameter_starts else len(comment))
- parent_comment = comment[:first_parameter_location]
-
- # We replace \n\n with <br/><br/> here and below, because the documentation
- # needs to know where the newlines should be, and this is easier than
- # escaping \n.
- parent_comment = (parent_comment.strip().replace('\n\n', '<br/><br/>')
- .replace('\n', ''))
+ parent_comment = (add_paragraphs(comment[:first_parameter_location].strip())
+ .replace('\n', ''))
params = OrderedDict()
for (cur_param, next_param) in itertools.izip_longest(parameter_starts,
@@ -79,9 +80,10 @@ def ProcessComment(comment):
# beginning of the next parameter's introduction.
param_comment_start = cur_param.end()
param_comment_end = next_param.start() if next_param else len(comment)
- params[param_name] = (comment[param_comment_start:param_comment_end
- ].strip().replace('\n\n', '<br/><br/>')
- .replace('\n', ''))
+ params[param_name] = (
+ add_paragraphs(comment[param_comment_start:param_comment_end].strip())
+ .replace('\n', ''))
+
return (parent_comment, params)
« no previous file with comments | « tools/json_schema_compiler/dart_test/comments.idl ('k') | tools/json_schema_compiler/idl_schema_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698