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):
return self._GenerateHandlebarContext(key,
self._idl_cache.GetFromFile(self._base_path + '/' + idl_path),
path)
except OSError as e:
except OSError:
raise
......@@ -30,9 +30,7 @@ IGNORED_FILES = [
'experimental',
'samples',
'index',
# These are APIs that should not have docs.
'test',
'experimental_idltest',
'devtools', # Has an intro, but marked as nodoc.
]
# 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):
contents = ('<h1 class="page_title">%s</h1>' % title) + 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):
processed_name = []
if name.startswith('experimental_'):
......@@ -216,6 +230,7 @@ def _MoveAllFiles(source_dir,
original_files.extend(files)
if replace:
_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))
unix_files = [_UnixName(f) for f in files]
for name in [SanitizeAPIName(f) for f in _ListAllAPIs(api_dir)]:
......
......@@ -3,7 +3,6 @@
# found in the LICENSE file.
import copy
import logging
import os
from docs_server_utils import GetLinkToRefType
......@@ -34,12 +33,10 @@ class HandlebarDictGenerator(object):
"""
def __init__(self, json):
clean_json = copy.deepcopy(json)
_RemoveNoDocs(clean_json)
try:
if _RemoveNoDocs(clean_json):
self._namespace = None
else:
self._namespace = model.Namespace(clean_json, clean_json['namespace'])
except Exception as e:
logging.error(e)
raise
def _StripPrefix(self, name):
if name.startswith(self._namespace.name + '.'):
......@@ -68,18 +65,16 @@ class HandlebarDictGenerator(object):
return ''.join(formatted_description)
def Generate(self, samples):
try:
return {
'name': self._namespace.name,
'types': map(self._GenerateType, self._namespace.types.values()),
'functions': self._GenerateFunctions(self._namespace.functions),
'events': map(self._GenerateEvent, self._namespace.events.values()),
'properties': self._GenerateProperties(self._namespace.properties),
'samples': samples,
}
except Exception as e:
logging.error(e)
raise
if self._namespace is None:
return { 'samples': samples }
return {
'name': self._namespace.name,
'types': map(self._GenerateType, self._namespace.types.values()),
'functions': self._GenerateFunctions(self._namespace.functions),
'events': map(self._GenerateEvent, self._namespace.events.values()),
'properties': self._GenerateProperties(self._namespace.properties),
'samples': samples,
}
def _GenerateType(self, type_):
type_dict = {
......
......@@ -12,8 +12,6 @@ import handler
from handler import Handler
KNOWN_FAILURES = [
# Exception in schema compiler (model.py). See http://crbug.com/141279.
'app.html',
]
class _MockResponse(object):
......
<h1>chrome.devtools.* APIs</h1>
<p>
The following API modules provide support for extending
Chrome Developer Tools:
......@@ -69,4 +71,4 @@ For information on the standard APIs that extensions can use, see
<p>
You can find examples that use Developer Tools APIs in
<a href="samples.html#devtools">Samples</a>.
</p>
\ No newline at end of file
</p>
{{+partials.standard_apps_api api:apis.app}}
\ No newline at end of file
{{+partials.standard_apps_api api:apis.devtools intro:intros.devtools}}
\ No newline at end of file
{{+partials.standard_apps_article article:intros.devtools}}
{{+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}}
\ No newline at end of file
{{+partials.standard_extensions_article article:intros.devtools}}
{{+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