diff --git a/scripts/generate_json_docs.py b/scripts/generate_json_docs.py index 1d055337ce99..3e25d600563c 100644 --- a/scripts/generate_json_docs.py +++ b/scripts/generate_json_docs.py @@ -22,14 +22,10 @@ import pdoc from parinx.parser import parse_docstring from parinx.errors import MethodParsingException +import six from verify_included_modules import get_public_modules -import gcloud - -ABSOLUTE_LIBRARY_PATH = os.path.dirname(os.path.dirname(os.path.abspath( - gcloud.__file__))) - class Module(object): @@ -46,9 +42,6 @@ def __init__(self, module_id, name, description=None, def from_module_name(cls, name, base_path): module = pdoc.Module(pdoc.import_module(name), allsubmodules=True) methods = module.functions() + module.variables() - - mod = __import__(name) - examples = [] if '__init__' in name: @@ -56,7 +49,7 @@ def from_module_name(cls, name, base_path): os.path.join(base_path, 'docs')) examples.extend(snippets) - source_path = clean_source_path(inspect.getsourcefile(mod)) + source_path = clean_source_path(module) return cls(module_id=name, name=name.split('.')[-1].title(), @@ -90,8 +83,7 @@ def from_class_name(cls, module, kls): methods = kls.methods() examples = [] - source_module = __import__(module.name) - source_path = clean_source_path(inspect.getsourcefile(source_module)) + source_path = clean_source_path(module) return cls(module_id=kls.name, name=kls.name.split('.')[-1].title(), @@ -254,19 +246,19 @@ def build_link_from_type(type_name, object_type=None): type_markup = '%s' % block} + block = {'code': '
%s
' % (block,)} formatted_blocks.append(block) return formatted_blocks @@ -349,11 +343,11 @@ def process_words(line): if word.startswith('``') and word.endswith('``'): word = word.replace('``', '') - word = '%s' % word + word = '%s' % (word,) if word.startswith('**') and word.endswith('**'): word = word.replace('**', '') - word = '%s' % word + word = '%s' % (word,) if word.startswith(':class:'): word = word.replace(':class:', '').replace('`', '') @@ -379,7 +373,7 @@ def process_words(line): if end_sentence: word += '.' - processed_line += ' %s' % word + processed_line += ' %s' % (word,) processed_line = processed_line.replace('::', '')