Skip to content

Commit

Permalink
Remove implicit relative imports within packages for Python 3.
Browse files Browse the repository at this point in the history
  • Loading branch information
buddly27 committed Jun 11, 2017
1 parent dd28ac4 commit 1211dba
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 19 deletions.
8 changes: 8 additions & 0 deletions doc/release_notes.rst
Expand Up @@ -4,6 +4,14 @@
Release Notes
*************

.. release:: 0.4.1
:date: 2017-06-11

.. change:: fixed

Remove implicit relative imports within packages for compatibility
with Python 3.

.. release:: 0.4.0
:date: 2017-06-11

Expand Down
2 changes: 1 addition & 1 deletion source/champollion/_version.py
@@ -1 +1 @@
__version__ = "0.4.0"
__version__ = "0.4.1"
12 changes: 6 additions & 6 deletions source/champollion/directive/base.py
Expand Up @@ -2,7 +2,7 @@

from sphinx.domains.javascript import JSObject

import rst_generator
from .rst_generator import rst_string


class BaseDirective(JSObject):
Expand Down Expand Up @@ -89,28 +89,28 @@ def generate_import_statement(
is_default = environment["default"]

if exported and is_default and not force_partial_import:
return rst_generator.rst_string(
return rst_string(
"``import {name} from \"{module}\"``\n".format(
name=name, module=module_name
)
)

if exported and (not is_default or force_partial_import):
return rst_generator.rst_string(
return rst_string(
"``import {{{name}}} from \"{module}\"``\n".format(
name=name, module=module_name
)
)

return rst_generator.rst_string()
return rst_string()

def generate_description(self, environment):
"""Return description generated from *environment*.
"""
description = environment["description"]

content = rst_generator.rst_string()
content = rst_string()
if description:
content += rst_generator.rst_string(description)
content += rst_string(description)

return content
9 changes: 6 additions & 3 deletions source/champollion/directive/class_element.py
Expand Up @@ -7,7 +7,10 @@

from .base import BaseDirective

import rst_generator
from .rst_generator import (
get_rst_attribute_elements,
get_rst_method_elements
)


def _parse_members(argument):
Expand Down Expand Up @@ -143,7 +146,7 @@ def before_content(self):
)

# Gather class attributes
rst_elements = rst_generator.get_rst_attribute_elements(
rst_elements = get_rst_attribute_elements(
env,
whitelist_names=whitelist,
blacklist_ids=env["method"].keys(),
Expand All @@ -153,7 +156,7 @@ def before_content(self):
)

# Gather class methods
rst_elements = rst_generator.get_rst_method_elements(
rst_elements = get_rst_method_elements(
env,
whitelist_names=whitelist,
skip_constructor=skip_constructor,
Expand Down
16 changes: 11 additions & 5 deletions source/champollion/directive/module_element.py
Expand Up @@ -4,7 +4,13 @@
import docutils.parsers.rst.directives
import docutils.nodes

import rst_generator
# import rst_generator
from .rst_generator import (
get_rst_class_elements,
get_rst_function_elements,
get_rst_data_elements,
get_rst_export_elements
)


class AutoModuleDirective(Directive):
Expand Down Expand Up @@ -91,7 +97,7 @@ def run(self):
rst_elements = {}

# Gather classes
rst_elements = rst_generator.get_rst_class_elements(
rst_elements = get_rst_class_elements(
env, module_name,
undocumented_members=undoc_members,
private_members=private_members,
Expand All @@ -102,7 +108,7 @@ def run(self):
)

# Gather functions
rst_elements = rst_generator.get_rst_function_elements(
rst_elements = get_rst_function_elements(
env, module_name,
undocumented_members=undoc_members,
private_members=private_members,
Expand All @@ -113,7 +119,7 @@ def run(self):
)

# Gather variables
rst_elements = rst_generator.get_rst_data_elements(
rst_elements = get_rst_data_elements(
env, module_name,
blacklist_ids=env["function"].keys(),
undocumented_members=undoc_members,
Expand All @@ -125,7 +131,7 @@ def run(self):
)

# Gather exported elements
rst_elements = rst_generator.get_rst_export_elements(
rst_elements = get_rst_export_elements(
env, js_env, module_name,
rst_elements=rst_elements
)
Expand Down
8 changes: 4 additions & 4 deletions source/champollion/parser/__init__.py
Expand Up @@ -6,8 +6,8 @@

import os

import module_element
import file_element
from .module_element import fetch_environment as fetch_module_environment
from .file_element import fetch_environment as fetch_file_environment


def fetch_environment(path):
Expand Down Expand Up @@ -127,7 +127,7 @@ def fetch_environment(path):
file_path = os.path.join(root, _file)

# Fetch module environment
_module_environment = module_element.fetch_environment(
_module_environment = fetch_module_environment(
file_id, files, module_names=[
_module["name"] for _module in
environment["module"].values()
Expand All @@ -137,7 +137,7 @@ def fetch_environment(path):
environment["module"][module_id] = _module_environment

# Fetch file environment
_file_environment = file_element.fetch_environment(
_file_environment = fetch_file_environment(
file_path, file_id, _module_environment["id"]
)
file_id = _file_environment["id"]
Expand Down

0 comments on commit 1211dba

Please sign in to comment.