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

Unified Diff: chrome/common/extensions/docs/server2/availability_finder.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/availability_finder.py
diff --git a/chrome/common/extensions/docs/server2/availability_finder.py b/chrome/common/extensions/docs/server2/availability_finder.py
index c0cf95e9bb79f776182202d75b3a69e0b415e141..ffa85293f727971d26477b65e6c8cec9ab411e81 100644
--- a/chrome/common/extensions/docs/server2/availability_finder.py
+++ b/chrome/common/extensions/docs/server2/availability_finder.py
@@ -7,7 +7,7 @@ import posixpath
from api_schema_graph import APISchemaGraph
from branch_utility import BranchUtility
-from extensions_paths import API, JSON_TEMPLATES
+from extensions_paths import API, CORE_API, JSON_TEMPLATES
from third_party.json_schema_compiler.model import UnixName
@@ -95,24 +95,28 @@ class AvailabilityFinder(object):
single _EXTENSION_API file which all APIs share in older versions of Chrome,
in which case it is unknown whether the API actually exists there.
'''
- def under_api_path(path):
- return API + path
+ def find_schema_under_path(api_name, path):
+ # |file_system| will cache the results from the ReadSingle() call.
+ if not file_system.Exists(path).Get():
+ return None
+ filenames = file_system.ReadSingle(path).Get()
+ for ext in ('json', 'idl'):
+ filename = '%s.%s' % (api_name, ext)
+ if filename in filenames:
+ return path + filename
+ if _EXTENSION_API in filenames:
+ return path + _EXTENSION_API
+ # API schema data could not be found in any .json or .idl file.
+ return None
if version == 'trunk' or version > _ORIGINAL_FEATURES_MIN_VERSION:
# API schema filenames switch format to unix_hacker_style.
api_name = UnixName(api_name)
- # |file_system| will cache the results from the ReadSingle() call.
- filenames = file_system.ReadSingle(API).Get()
-
- for ext in ('json', 'idl'):
- filename = '%s.%s' % (api_name, ext)
- if filename in filenames:
- return under_api_path(filename)
- if _EXTENSION_API in filenames:
- return under_api_path(_EXTENSION_API)
- # API schema data could not be found in any .json or .idl file.
- return None
+ filename = find_schema_under_path(api_name, CORE_API)
+ if filename is not None:
+ return filename
+ return find_schema_under_path(api_name, API)
def _GetApiSchema(self, api_name, file_system, version):
'''Searches |file_system| for |api_name|'s API schema data, and processes

Powered by Google App Engine
This is Rietveld 408576698