Skip to content
This repository has been archived by the owner on Feb 28, 2022. It is now read-only.

Commit

Permalink
change EGG package path to friendly name path
Browse files Browse the repository at this point in the history
  • Loading branch information
bianliu1013 committed Jun 20, 2017
1 parent 20d6e4a commit 9c662cc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
23 changes: 22 additions & 1 deletion docfx_yaml/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""
import os
import inspect
import re
from functools import partial

try:
Expand Down Expand Up @@ -158,6 +159,23 @@ def _create_datam(app, cls, module, name, _type, obj, lines=None):
Build the data structure for an autodoc class
"""

def _update_friendly_package_name(path):
package_name_index = path.find(os.sep)
package_name = path[:package_name_index]
if len(package_name) > 0:
try:
for name in namespace_package_dict:
if re.match(name, package_name) is not None:
package_name = namespace_package_dict[name]
path = os.path.join(package_name, path[package_name_index + 1:])
return path

except NameError:
pass

return path


if lines is None:
lines = []
short_name = name.split('.')[-1]
Expand Down Expand Up @@ -188,10 +206,13 @@ def _create_datam(app, cls, module, name, _type, obj, lines=None):
import_path = os.path.dirname(inspect.getfile(os))
path = path.replace(os.path.join(import_path, 'site-packages'), '')
path = path.replace(import_path, '')

# Make relative
path = path.replace('/', '', 1)
path = path.replace(os.sep, '', 1)
start_line = inspect.getsourcelines(obj)[1]

path = _update_friendly_package_name(path)

# append relative path defined in conf.py (in case of "binding python" project)
try:
source_prefix # does source_prefix exist in the current namespace
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

setup(
name='sphinx-docfx-yaml',
version='1.2.4',
version='1.2.9',
author='Eric Holscher',
author_email='eric@ericholscher.com',
url='https://github.com/ericholscher/sphinx-docfx-yaml',
Expand Down

0 comments on commit 9c662cc

Please sign in to comment.