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

Side by Side Diff: chrome/common/extensions/docs/server2/api_categorizer.py

Issue 2738623003: Extensions: Fix DocServer assert failures. (Closed)
Patch Set: -- Created 3 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 unified diff | Download patch
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import os 5 import os
6 import posixpath 6 import posixpath
7 7
8 from compiled_file_system import SingleFile 8 from compiled_file_system import SingleFile
9 from extensions_paths import PUBLIC_TEMPLATES 9 from extensions_paths import PUBLIC_TEMPLATES
10 10
(...skipping 16 matching lines...) Expand all
27 @SingleFile 27 @SingleFile
28 def _CollectDocumentedAPIs(self, base_dir, files): 28 def _CollectDocumentedAPIs(self, base_dir, files):
29 public_templates = [] 29 public_templates = []
30 for root, _, files in self._file_system.Walk(base_dir): 30 for root, _, files in self._file_system.Walk(base_dir):
31 public_templates.extend(posixpath.join(root, name) for name in files) 31 public_templates.extend(posixpath.join(root, name) for name in files)
32 template_names = set(os.path.splitext(name)[0].replace('_', '.') 32 template_names = set(os.path.splitext(name)[0].replace('_', '.')
33 for name in public_templates) 33 for name in public_templates)
34 return template_names 34 return template_names
35 35
36 def GetCategory(self, api_name): 36 def GetCategory(self, api_name):
37 '''Return the type of api.'Chrome' means the public apis, 37 '''Returns the type of api:
38 private means the api only used by chrome, and experimental means 38 "internal": Used by chrome internally. Never documented.
39 the apis with "experimental" prefix. 39 "private": APIs which are undocumented or are available to
40 whitelisted apps/extensions.
41 "experimental": Experimental APIs.
42 "chrome": Public APIs.
40 ''' 43 '''
41 documented_apis = self._GenerateAPICategories() 44 documented_apis = self._GenerateAPICategories()
45 if api_name.endswith('Internal'):
46 assert api_name not in documented_apis, \
karandeepb 2017/03/10 03:13:37 Do we have a common tool we use to format python f
47 "Internal API %s on %s platform should not be documented" % (
48 api_name, self._platform)
49 return 'internal'
42 if (api_name.endswith('Private') or 50 if (api_name.endswith('Private') or
43 api_name not in documented_apis): 51 api_name not in documented_apis):
44 return 'private' 52 return 'private'
45 if api_name.startswith('experimental.'): 53 if api_name.startswith('experimental.'):
46 return 'experimental' 54 return 'experimental'
47 return 'chrome' 55 return 'chrome'
48 56
49 def IsDocumented(self, api_name): 57 def IsDocumented(self, api_name):
50 return (api_name in self._GenerateAPICategories()) 58 return (api_name in self._GenerateAPICategories())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698