Skip to content

Commit

Permalink
Fix tuple syntax.
Browse files Browse the repository at this point in the history
  • Loading branch information
daspecster committed Aug 17, 2016
1 parent 97d6efe commit 4481eef
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions scripts/generate_json_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import json
import os
import shutil
import six
import types

import pdoc
Expand All @@ -25,11 +26,6 @@

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):

Expand Down Expand Up @@ -103,7 +99,7 @@ def to_dict(self):
'description': format_sphinx_doc(self.description),
'examples': self.examples,
'methods': [m.to_dict() for m in self.methods],
'source': '%s' % self.source}
'source': self.source}


class Method(object):
Expand Down Expand Up @@ -250,7 +246,7 @@ def build_link_from_type(type_name, object_type=None):
type_markup = '<a data-custom-type="%s"' % doc_path
if object_type == 'instance':
type_markup += ' data-method="%s"' % type_name
type_markup += '>%s</a>' % type_name
type_markup += '>%s</a>' % (type_name,)

return type_markup

Expand All @@ -261,7 +257,7 @@ def build_source(module, method):
types.TracebackType, types.FrameType,
types.CodeType, types.TypeType)):

line = inspect.getsourcelines(module)[1]
_, line = inspect.getsourcelines(module)
source_path = clean_source_path(module)

if line:
Expand Down Expand Up @@ -291,13 +287,13 @@ def build_type(type_id, title, contents):


def clean_source_path(module):
if isinstance(module, str):
if isinstance(module, six.string_types):
source_id = module
elif hasattr(module, 'refname'):
source_id = module.refname
else:
source_id = inspect.getmodule(module).__name__
return '%s.py' % source_id.replace('.', '/')
return '%s.py' % (source_id.replace('.', '/'),)


def process_code_blocks(doc):
Expand All @@ -319,7 +315,7 @@ def process_code_blocks(doc):
is_code = True

if is_code:
block = {'code': '<pre><code>%s</code></pre>' % block}
block = {'code': '<pre><code>%s</code></pre>' % (block,)}

formatted_blocks.append(block)
return formatted_blocks
Expand All @@ -333,7 +329,7 @@ def format_sphinx_doc(doc):
line = line['code']
else:
line = process_words(line)
example_lines = '%s\n%s' % (example_lines, line)
example_lines = '%s\n%s' % (example_lines, line,)
return example_lines


Expand All @@ -347,11 +343,11 @@ def process_words(line):

if word.startswith('``') and word.endswith('``'):
word = word.replace('``', '')
word = '<code>%s</code>' % word
word = '<code>%s</code>' % (word,)

if word.startswith('**') and word.endswith('**'):
word = word.replace('**', '')
word = '<b>%s</b>' % word
word = '<b>%s</b>' % (word,)

if word.startswith(':class:'):
word = word.replace(':class:', '').replace('`', '')
Expand All @@ -372,12 +368,12 @@ def process_words(line):
word = word.replace('`', '')

if word.startswith('https://') or word.startswith('http://'):
word = '<a href="%s">%s</a>' % (word, word)
word = '<a href="%s">%s</a>' % (word, word,)

if end_sentence:
word += '.'

processed_line += ' %s' % word
processed_line += ' %s' % (word,)

processed_line = processed_line.replace('::', '')

Expand Down

0 comments on commit 4481eef

Please sign in to comment.