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

Issue 10577022: Extensions Docs Server: HandlebarDictGenerator (Closed)

Created:
8 years, 6 months ago by cduvall
Modified:
8 years, 6 months ago
CC:
chromium-reviews, Aaron Boodman, mihaip-chromium-reviews_chromium.org, clintstaley
Visibility:
Public.

Description

Extensions Docs Server: DictGenerator Implemented the HandlebarDictGenerator that works with the JSON Schema Compiler to produce a dictionary that Handlebar can work with. The HandlebarDictGenerator removes all items marked "nodoc", and only keeps the necessary parts of the JSON. $refs can be resolved because, if the dependencies are in other files, they are formatted as "dependency.Item" (eg. windows.Window), so the link can be created based on this name. APIDataSource now uses a DictGenerator instead of the raw JSON APIs. BUG=131095 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=143208

Patch Set 1 #

Total comments: 18

Patch Set 2 : Clean up #

Total comments: 12

Patch Set 3 : minor changes #

Messages

Total messages: 5 (0 generated)
cduvall
DictGenerator is here. Let me know if this is on the right track.
8 years, 6 months ago (2012-06-19 18:59:38 UTC) #1
not at google - send to devlin
This is the right idea. I didn't look at it too thoroughly since I have ...
8 years, 6 months ago (2012-06-19 20:33:10 UTC) #2
cduvall
I expect to be changing this once I start generating HTML, but I think the ...
8 years, 6 months ago (2012-06-19 22:21:01 UTC) #3
not at google - send to devlin
lgtm with comments. Let's get this submitted and start writing some templates (woo). http://codereview.chromium.org/10577022/diff/11/chrome/common/extensions/docs/server2/handlebar_dict_generator.py File ...
8 years, 6 months ago (2012-06-20 18:11:53 UTC) #4
cduvall
8 years, 6 months ago (2012-06-20 18:24:49 UTC) #5
http://codereview.chromium.org/10577022/diff/11/chrome/common/extensions/docs...
File chrome/common/extensions/docs/server2/handlebar_dict_generator.py (right):

http://codereview.chromium.org/10577022/diff/11/chrome/common/extensions/docs...
chrome/common/extensions/docs/server2/handlebar_dict_generator.py:27:
_RemoveNoDocs(json)
On 2012/06/20 18:11:53, kalman wrote:
> Would prefer not to modify the input json here. Make a copy first?

Done.

http://codereview.chromium.org/10577022/diff/11/chrome/common/extensions/docs...
chrome/common/extensions/docs/server2/handlebar_dict_generator.py:53:
type_dict['item_type'] = self._GenerateType(type_.item_type)
On 2012/06/20 18:11:53, kalman wrote:
> It's this kind of stuff that I think will end up changing when we actually
write
> the template for rendering a type. I.e. we will certainly need to know what
the
> item type of an array is so that we can render "array of string" but I see
this
> more as having a separate dictionary called "array", like
> 
> if type_.type == ARRAY:
>   type_dict['array'] = {
>     'type': self._GenerateType(type_.item_type)
>   }
> 
> and the templates will have like
> 
> {{?array}}
> array of {{type.type}}
> {{/}}
> 
> as opposed to
> 
> {{?item_type}}
> array of {{type.type}}
> {{/}}
> 
> A trivial example really, but anyway, that's just something to keep in mind.
> 
> So: how about just changing the key to "array" for now and seeing what
happens.

Done.

http://codereview.chromium.org/10577022/diff/11/chrome/common/extensions/docs...
chrome/common/extensions/docs/server2/handlebar_dict_generator.py:104:
property_dict['item_type'] = self._GenerateProperty(property_.item_type)
On 2012/06/20 18:11:53, kalman wrote:
> ditto, my comment above applies to all these "type == Foo" things. 'ref_type'
->
> 'ref', 'item_type' -> 'array'.

Done.

http://codereview.chromium.org/10577022/diff/11/chrome/common/extensions/docs...
File chrome/common/extensions/docs/server2/handlebar_dict_generator_test.py
(right):

http://codereview.chromium.org/10577022/diff/11/chrome/common/extensions/docs...
chrome/common/extensions/docs/server2/handlebar_dict_generator_test.py:20:
return f.read()
On 2012/06/20 18:11:53, kalman wrote:
> observation: a lot of tests seem to have this pattern. Consider having your
own
> test class that inherits from unittest.TestCase that can set up your testing
> environment.
> 
> (not in this patch though)

Good idea.

http://codereview.chromium.org/10577022/diff/11/chrome/common/extensions/docs...
chrome/common/extensions/docs/server2/handlebar_dict_generator_test.py:29:
self._GenerateTest('test_file.json')
On 2012/06/20 18:11:53, kalman wrote:
> why this indirection?

I just wanted to make it easier to have similar tests that use different test
files.

http://codereview.chromium.org/10577022/diff/11/chrome/common/extensions/docs...
File chrome/common/extensions/docs/server2/template_data_source.py (right):

http://codereview.chromium.org/10577022/diff/11/chrome/common/extensions/docs...
chrome/common/extensions/docs/server2/template_data_source.py:27: return
template.render(context, self).text
On 2012/06/20 18:11:53, kalman wrote:
> Why this change? Unless I'm misunderstanding, it means that any misspelled
> variable name in the templates will fall through to here, which will grab
stuff
> from the fetcher.
> 
> I guess that's not a big deal provided we cache cache-misses too (do we?).
> 
> But I also just kinda like the fact that the sub-templates are namespaced.
Avoid
> potential problems with overriding references in the templates later on.

Yeah, I changed this because I thought it would work better (and didn't
completely understand partials at the time), but  I changed it back when I was
messing with implementing a sample template.

Powered by Google App Engine
This is Rietveld 408576698