Commit 26bd483d authored by cduvall@chromium.org's avatar cduvall@chromium.org

Extensions Docs Server: Fix handling of nodocs

The conversion script will now not generate templates for APIs marked as nodoc.
The server also handles them gracefully if they slip in and 404s.

BUG=141279

Review URL: https://chromiumcodereview.appspot.com/10854054

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151068 0039d316-1c4b-4281-b951-d872f2087c98
parent 562b113e
...@@ -95,5 +95,5 @@ class APIDataSource(object): ...@@ -95,5 +95,5 @@ class APIDataSource(object):
return self._GenerateHandlebarContext(key, return self._GenerateHandlebarContext(key,
self._idl_cache.GetFromFile(self._base_path + '/' + idl_path), self._idl_cache.GetFromFile(self._base_path + '/' + idl_path),
path) path)
except OSError as e: except OSError:
raise raise
...@@ -30,9 +30,7 @@ IGNORED_FILES = [ ...@@ -30,9 +30,7 @@ IGNORED_FILES = [
'experimental', 'experimental',
'samples', 'samples',
'index', 'index',
# These are APIs that should not have docs. 'devtools', # Has an intro, but marked as nodoc.
'test',
'experimental_idltest',
] ]
# These are mappings for APIs that have no intros. They are needed because the # These are mappings for APIs that have no intros. They are needed because the
...@@ -186,6 +184,22 @@ def _FormatFile(contents, path, name, image_dest, replace, is_api): ...@@ -186,6 +184,22 @@ def _FormatFile(contents, path, name, image_dest, replace, is_api):
contents = ('<h1 class="page_title">%s</h1>' % title) + contents contents = ('<h1 class="page_title">%s</h1>' % title) + contents
return contents return contents
def _GetNoDocs(api_dir, api_files):
exclude = []
for api in api_files:
try:
with open(os.path.join(api_dir, api), 'r') as f:
if os.path.splitext(api)[-1] == '.idl':
if '[nodoc] namespace' in f.read():
exclude.append(_UnixName(api))
else:
api_json = json.loads(json_comment_eater.Nom(f.read()))
if api_json[0].get('nodoc', False):
exclude.append(_UnixName(api))
except Exception:
pass
return exclude
def _ProcessName(name): def _ProcessName(name):
processed_name = [] processed_name = []
if name.startswith('experimental_'): if name.startswith('experimental_'):
...@@ -216,6 +230,7 @@ def _MoveAllFiles(source_dir, ...@@ -216,6 +230,7 @@ def _MoveAllFiles(source_dir,
original_files.extend(files) original_files.extend(files)
if replace: if replace:
_CleanAPIs(source_dir, api_dir, intros_dest, template_dest, exclude_files) _CleanAPIs(source_dir, api_dir, intros_dest, template_dest, exclude_files)
exclude_files.extend(_GetNoDocs(api_dir, api_files))
files = set(os.listdir(source_dir)) files = set(os.listdir(source_dir))
unix_files = [_UnixName(f) for f in files] unix_files = [_UnixName(f) for f in files]
for name in [SanitizeAPIName(f) for f in _ListAllAPIs(api_dir)]: for name in [SanitizeAPIName(f) for f in _ListAllAPIs(api_dir)]:
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
# found in the LICENSE file. # found in the LICENSE file.
import copy import copy
import logging
import os import os
from docs_server_utils import GetLinkToRefType from docs_server_utils import GetLinkToRefType
...@@ -34,12 +33,10 @@ class HandlebarDictGenerator(object): ...@@ -34,12 +33,10 @@ class HandlebarDictGenerator(object):
""" """
def __init__(self, json): def __init__(self, json):
clean_json = copy.deepcopy(json) clean_json = copy.deepcopy(json)
_RemoveNoDocs(clean_json) if _RemoveNoDocs(clean_json):
try: self._namespace = None
else:
self._namespace = model.Namespace(clean_json, clean_json['namespace']) self._namespace = model.Namespace(clean_json, clean_json['namespace'])
except Exception as e:
logging.error(e)
raise
def _StripPrefix(self, name): def _StripPrefix(self, name):
if name.startswith(self._namespace.name + '.'): if name.startswith(self._namespace.name + '.'):
...@@ -68,7 +65,8 @@ class HandlebarDictGenerator(object): ...@@ -68,7 +65,8 @@ class HandlebarDictGenerator(object):
return ''.join(formatted_description) return ''.join(formatted_description)
def Generate(self, samples): def Generate(self, samples):
try: if self._namespace is None:
return { 'samples': samples }
return { return {
'name': self._namespace.name, 'name': self._namespace.name,
'types': map(self._GenerateType, self._namespace.types.values()), 'types': map(self._GenerateType, self._namespace.types.values()),
...@@ -77,9 +75,6 @@ class HandlebarDictGenerator(object): ...@@ -77,9 +75,6 @@ class HandlebarDictGenerator(object):
'properties': self._GenerateProperties(self._namespace.properties), 'properties': self._GenerateProperties(self._namespace.properties),
'samples': samples, 'samples': samples,
} }
except Exception as e:
logging.error(e)
raise
def _GenerateType(self, type_): def _GenerateType(self, type_):
type_dict = { type_dict = {
......
...@@ -12,8 +12,6 @@ import handler ...@@ -12,8 +12,6 @@ import handler
from handler import Handler from handler import Handler
KNOWN_FAILURES = [ KNOWN_FAILURES = [
# Exception in schema compiler (model.py). See http://crbug.com/141279.
'app.html',
] ]
class _MockResponse(object): class _MockResponse(object):
......
<h1>chrome.devtools.* APIs</h1>
<p> <p>
The following API modules provide support for extending The following API modules provide support for extending
Chrome Developer Tools: Chrome Developer Tools:
......
{{+partials.standard_apps_api api:apis.app}}
\ No newline at end of file
{{+partials.standard_apps_api api:apis.devtools intro:intros.devtools}} {{+partials.standard_apps_article article:intros.devtools}}
\ No newline at end of file
{{+partials.standard_apps_api api:apis.experimental_accessibility}}
\ No newline at end of file
{{+partials.standard_apps_api api:apis.experimental_bookmark_manager}}
\ No newline at end of file
{{+partials.standard_apps_api api:apis.experimental_dns}}
\ No newline at end of file
{{+partials.standard_apps_api api:apis.experimental_input_virtual_keyboard}}
\ No newline at end of file
{{+partials.standard_apps_api api:apis.experimental_push_messaging}}
\ No newline at end of file
{{+partials.standard_apps_api api:apis.experimental_rlz}}
\ No newline at end of file
{{+partials.standard_apps_api api:apis.page_actions}}
\ No newline at end of file
{{+partials.standard_extensions_api api:apis.devtools intro:intros.devtools}} {{+partials.standard_extensions_article article:intros.devtools}}
\ No newline at end of file
{{+partials.standard_extensions_api api:apis.experimental_accessibility}}
\ No newline at end of file
{{+partials.standard_extensions_api api:apis.experimental_bookmark_manager}}
\ No newline at end of file
{{+partials.standard_extensions_api api:apis.experimental_input_virtual_keyboard}}
\ No newline at end of file
{{+partials.standard_extensions_api api:apis.experimental_push_messaging}}
\ No newline at end of file
{{+partials.standard_extensions_api api:apis.experimental_rlz}}
\ No newline at end of file
{{+partials.standard_extensions_api api:apis.page_actions}}
\ No newline at end of file
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