Commit 355a414b authored by kalman@chromium.org's avatar kalman@chromium.org

Extension docs: Make comments in IDL files generate paragraphs rather than

double <br> elements, and adjust CSS to make it look good. Fix up a couple of
IDL files to just use newlines rather than <br> elements.

R=mangini@chromium.org, asargent@chromium.org
NOTRY=true

Review URL: https://codereview.chromium.org/404203002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284571 0039d316-1c4b-4281-b951-d872f2087c98
parent aa92ff03
...@@ -99,28 +99,35 @@ namespace app.window { ...@@ -99,28 +99,35 @@ namespace app.window {
dictionary FrameOptions { dictionary FrameOptions {
// Frame type: <code>none</code> or <code>chrome</code> (defaults to // Frame type: <code>none</code> or <code>chrome</code> (defaults to
// <code>chrome</code>).<br> // <code>chrome</code>).
//
// For <code>none</code>, the <code>-webkit-app-region</code> CSS property // For <code>none</code>, the <code>-webkit-app-region</code> CSS property
// can be used to apply draggability to the app's window. // can be used to apply draggability to the app's window.
//
// <code>-webkit-app-region: drag</code> can be used to mark regions // <code>-webkit-app-region: drag</code> can be used to mark regions
// draggable. <code>no-drag</code> can be used to disable this style on // draggable. <code>no-drag</code> can be used to disable this style on
// nested elements.<br> // nested elements.
DOMString? type; DOMString? type;
// Allows the frame color to be set. Frame coloring is only available if the // Allows the frame color to be set. Frame coloring is only available if the
// frame type is <code>chrome</code>.<br> // frame type is <code>chrome</code>.
//
// Frame coloring is new in Chrome 36. // Frame coloring is new in Chrome 36.
DOMString? color; DOMString? color;
// Allows the frame color of the window when active to be set. Frame // Allows the frame color of the window when active to be set. Frame
// coloring is only available if the frame type is <code>chrome</code>.<br> // coloring is only available if the frame type is <code>chrome</code>.
//
// Frame coloring is only available if the frame type is // Frame coloring is only available if the frame type is
// <code>chrome</code>.<br> // <code>chrome</code>.
//
// Frame coloring is new in Chrome 36. // Frame coloring is new in Chrome 36.
DOMString? activeColor; DOMString? activeColor;
// Allows the frame color of the window when inactive to be set differently // Allows the frame color of the window when inactive to be set differently
// to the active color. Frame // to the active color. Frame
// coloring is only available if the frame type is <code>chrome</code>.<br> // coloring is only available if the frame type is <code>chrome</code>.
//
// <code>inactiveColor</code> must be used in conjunction with <code> // <code>inactiveColor</code> must be used in conjunction with <code>
// color</code>.<br> // color</code>.
//
// Frame coloring is new in Chrome 36. // Frame coloring is new in Chrome 36.
DOMString? inactiveColor; DOMString? inactiveColor;
}; };
...@@ -213,7 +220,8 @@ namespace app.window { ...@@ -213,7 +220,8 @@ namespace app.window {
// <code>-webkit-app-region</code> CSS property can be used to apply // <code>-webkit-app-region</code> CSS property can be used to apply
// draggability to the app's window. <code>-webkit-app-region: drag</code> // draggability to the app's window. <code>-webkit-app-region: drag</code>
// can be used to mark regions draggable. <code>no-drag</code> can be used // can be used to mark regions draggable. <code>no-drag</code> can be used
// to disable this style on nested elements.<br> // to disable this style on nested elements.
//
// Use of <code>FrameOptions</code> is new in M36. // Use of <code>FrameOptions</code> is new in M36.
(DOMString or FrameOptions)? frame; (DOMString or FrameOptions)? frame;
...@@ -247,9 +255,10 @@ namespace app.window { ...@@ -247,9 +255,10 @@ namespace app.window {
// If true, the window will stay above most other windows. If there are // If true, the window will stay above most other windows. If there are
// multiple windows of this kind, the currently focused window will be in // multiple windows of this kind, the currently focused window will be in
// the foreground. Requires the <code>"alwaysOnTopWindows"</code> // the foreground. Requires the <code>"alwaysOnTopWindows"</code>
// permission. Defaults to false.<br> // permission. Defaults to false.
//
// Call <code>setAlwaysOnTop()</code> on the window to change this property // Call <code>setAlwaysOnTop()</code> on the window to change this property
// after creation.<br> // after creation.
boolean? alwaysOnTop; boolean? alwaysOnTop;
// If true, the window will be focused when created. Defaults to true. // If true, the window will be focused when created. Defaults to true.
...@@ -258,10 +267,13 @@ namespace app.window { ...@@ -258,10 +267,13 @@ namespace app.window {
// Called in the creating window (parent) before the load event is called in // Called in the creating window (parent) before the load event is called in
// the created window (child). The parent can set fields or functions on the // the created window (child). The parent can set fields or functions on the
// child usable from onload. E.g. background.js:<br> // child usable from onload. E.g. background.js:
//
// <code>function(createdWindow) { createdWindow.contentWindow.foo = // <code>function(createdWindow) { createdWindow.contentWindow.foo =
// function () { }; };</code> // function () { }; };</code>
// <br>window.js:<br> //
// window.js:
//
// <code>window.onload = function () { foo(); }</code> // <code>window.onload = function () { foo(); }</code>
callback CreateWindowCallback = callback CreateWindowCallback =
void ([instanceOf=AppWindow] object createdWindow); void ([instanceOf=AppWindow] object createdWindow);
...@@ -270,11 +282,13 @@ namespace app.window { ...@@ -270,11 +282,13 @@ namespace app.window {
// Focus the window. // Focus the window.
static void focus(); static void focus();
// Fullscreens the window.<br> // Fullscreens the window.
//
// The user will be able to restore the window by pressing ESC. An // The user will be able to restore the window by pressing ESC. An
// application can prevent the fullscreen state to be left when ESC is // application can prevent the fullscreen state to be left when ESC is
// pressed by requesting the <b>overrideEscFullscreen</b> permission and // pressed by requesting the <b>overrideEscFullscreen</b> permission and
// canceling the event by calling .preventDefault(), like this:<br> // canceling the event by calling .preventDefault(), like this:
//
// <code>window.onKeyDown = function(e) { if (e.keyCode == 27 /* ESC */) { // <code>window.onKeyDown = function(e) { if (e.keyCode == 27 /* ESC */) {
// e.preventDefault(); } };</code> // e.preventDefault(); } };</code>
static void fullscreen(); static void fullscreen();
......
...@@ -77,7 +77,8 @@ namespace identity { ...@@ -77,7 +77,8 @@ namespace identity {
interface Functions { interface Functions {
// Retrieves a list of AccountInfo objects describing the accounts // Retrieves a list of AccountInfo objects describing the accounts
// present on the profile.<br> // present on the profile.
//
// <code>getAccounts</code> is only supported on dev channel. // <code>getAccounts</code> is only supported on dev channel.
static void getAccounts(GetAccountsCallback callback); static void getAccounts(GetAccountsCallback callback);
......
application: chrome-apps-doc application: chrome-apps-doc
version: 3-33-0 version: 3-34-0
runtime: python27 runtime: python27
api_version: 1 api_version: 1
threadsafe: false threadsafe: false
......
...@@ -2,4 +2,4 @@ cron: ...@@ -2,4 +2,4 @@ cron:
- description: Repopulates all cached data. - description: Repopulates all cached data.
url: /_cron url: /_cron
schedule: every 5 minutes schedule: every 5 minutes
target: 3-33-0 target: 3-34-0
...@@ -17,17 +17,23 @@ ...@@ -17,17 +17,23 @@
.description { .description {
margin-left: 20px; margin-left: 20px;
} }
table.innerTable { table {
margin: 10px 0; .innerTable {
td, th { margin: 10px 0;
padding: 5px 10px; td, th {
border: 1px solid #eee; padding: 5px 10px;
} border: 1px solid #eee;
th { }
background: none; th {
background: none;
}
} }
p { p {
margin: 0; margin-top: 0.75em;
margin-bottom: 0.75em;
}
p:first-child {
margin-top: 0;
} }
} }
td, th { td, th {
......
...@@ -18,12 +18,12 @@ class API_comments { ...@@ -18,12 +18,12 @@ class API_comments {
/* /*
* Functions * Functions
*/ */
/// There's a blank line at the start of this comment. Documentation for /// <p>There's a blank line at the start of this comment.</p><p>Documentation
/// basicFunction. BasicFunction() is a great function. There is a newline /// for basicFunction. BasicFunction() is a great function. There is a newline
/// after this.<br/><br/> It works like so: +-----+ | | /// after this.</p><p>It works like so: +-----+ | | +--+
/// +--+ | | | | +-----+ --> +--+<br/><br/> Some other /// | | | | +-----+ --> +--+</p><p>Some other stuff here.
/// stuff here. This paragraph starts with whitespace. Overall, its a /// This paragraph starts with whitespace. Overall, its a great function.
/// great function. There's also a blank line at the end of this comment. /// There's also a blank line at the end of this comment.</p>
void basicFunction() => JS('void', '#.basicFunction()', this._jsObject); void basicFunction() => JS('void', '#.basicFunction()', this._jsObject);
API_comments(this._jsObject) { API_comments(this._jsObject) {
......
...@@ -11,7 +11,7 @@ namespace comments { ...@@ -11,7 +11,7 @@ namespace comments {
// //
// There's a blank line at the start of this comment. // There's a blank line at the start of this comment.
// //
// Documentation for basicFunction. // Documentation for basicFunction.
// BasicFunction() is a great function. // BasicFunction() is a great function.
// There is a newline after this. // There is a newline after this.
......
...@@ -56,19 +56,20 @@ def ProcessComment(comment): ...@@ -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'. # Find all the parameter comments of the form '|name|: comment'.
parameter_starts = list(re.finditer(r' *\|([^|]*)\| *: *', comment)) parameter_starts = list(re.finditer(r' *\|([^|]*)\| *: *', comment))
# Get the parent comment (everything before the first parameter comment. # Get the parent comment (everything before the first parameter comment.
first_parameter_location = (parameter_starts[0].start() first_parameter_location = (parameter_starts[0].start()
if parameter_starts else len(comment)) if parameter_starts else len(comment))
parent_comment = comment[:first_parameter_location] parent_comment = (add_paragraphs(comment[:first_parameter_location].strip())
.replace('\n', ''))
# 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', ''))
params = OrderedDict() params = OrderedDict()
for (cur_param, next_param) in itertools.izip_longest(parameter_starts, for (cur_param, next_param) in itertools.izip_longest(parameter_starts,
...@@ -79,9 +80,10 @@ def ProcessComment(comment): ...@@ -79,9 +80,10 @@ def ProcessComment(comment):
# beginning of the next parameter's introduction. # beginning of the next parameter's introduction.
param_comment_start = cur_param.end() param_comment_start = cur_param.end()
param_comment_end = next_param.start() if next_param else len(comment) param_comment_end = next_param.start() if next_param else len(comment)
params[param_name] = (comment[param_comment_start:param_comment_end params[param_name] = (
].strip().replace('\n\n', '<br/><br/>') add_paragraphs(comment[param_comment_start:param_comment_end].strip())
.replace('\n', '')) .replace('\n', ''))
return (parent_comment, params) return (parent_comment, params)
......
...@@ -226,9 +226,10 @@ class IdlSchemaTest(unittest.TestCase): ...@@ -226,9 +226,10 @@ class IdlSchemaTest(unittest.TestCase):
'$ref': 'MyType1'}], '$ref': 'MyType1'}],
func['parameters']) func['parameters'])
func = getFunction(schema, 'function4') func = getFunction(schema, 'function4')
self.assertEquals(('This tests if "double-quotes" are escaped correctly.' self.assertEquals(
'<br/><br/> It also tests a comment with two newlines.'), '<p>This tests if "double-quotes" are escaped correctly.</p>'
func['description']) '<p>It also tests a comment with two newlines.</p>',
func['description'])
def testReservedWords(self): def testReservedWords(self):
schema = idl_schema.Load('test/idl_reserved_words.idl')[0] schema = idl_schema.Load('test/idl_reserved_words.idl')[0]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment