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

Unified Diff: chrome/common/extensions/docs/server2/api_models.py

Issue 176973009: Doc server: support interfaces in src/extensions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 6 years, 9 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
Index: chrome/common/extensions/docs/server2/api_models.py
diff --git a/chrome/common/extensions/docs/server2/api_models.py b/chrome/common/extensions/docs/server2/api_models.py
index 1875a1e329ac15732de66e410272265e32496bb4..cf9b1cc266e7f04db05de17a9229b01dd7435974 100644
--- a/chrome/common/extensions/docs/server2/api_models.py
+++ b/chrome/common/extensions/docs/server2/api_models.py
@@ -6,7 +6,7 @@ import os
import posixpath
from compiled_file_system import SingleFile, Unicode
-from extensions_paths import API
+from extensions_paths import API, CHROME_API
from file_system import FileNotFoundError
from future import Gettable, Future
from schema_util import ProcessSchema
@@ -29,6 +29,7 @@ class APIModels(object):
self._features_bundle = features_bundle
self._model_cache = compiled_fs_factory.Create(
file_system, _CreateAPIModel, APIModels)
+ self._file_system = file_system
def GetNames(self):
# API names appear alongside some of their methods/events/etc in the
@@ -45,11 +46,14 @@ class APIModels(object):
# Callers sometimes specify a filename which includes .json or .idl - if
# so, believe them. They may even include the 'api/' prefix.
if os.path.splitext(api_name)[1] in ('.json', '.idl'):
- if not api_name.startswith(API):
- api_name = posixpath.join(API, api_name)
+ if not api_name.startswith((API, CHROME_API)):
+ api_path = posixpath.join(API, api_name)
+ if self._file_system.Exists(api_path).Get():
+ return self._model_cache.GetFromFile(api_path)
+ api_name = posixpath.join(CHROME_API, api_name)
return self._model_cache.GetFromFile(api_name)
- assert not api_name.startswith(API)
+ assert not api_name.startswith((API, CHROME_API))
# API names are given as declarativeContent and app.window but file names
# will be declarative_content and app_window.
@@ -63,14 +67,15 @@ class APIModels(object):
basename.replace('devtools_' , '')))
futures = [self._model_cache.GetFromFile(
- posixpath.join(API, '%s.%s' % (file_name, ext)))
- for ext in ('json', 'idl')]
+ posixpath.join(api_path, '%s.%s' % (file_name, ext)))
+ for ext in ('json', 'idl')
+ for api_path in (API, CHROME_API)]
def resolve():
for future in futures:
try:
return future.Get()
except FileNotFoundError: pass
- # Propagate the first FileNotFoundError if neither were found.
+ # Propagate the first FileNotFoundError if no files were found.
futures[0].Get()
return Future(delegate=Gettable(resolve))

Powered by Google App Engine
This is Rietveld 408576698