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

Commit

Permalink
Merge pull request #25 from ericholscher/jinhwa/fix_bug_git_path
Browse files Browse the repository at this point in the history
fix git source path issue
  • Loading branch information
bianliu1013 committed May 26, 2017
2 parents 9708559 + ac0f951 commit dda942a
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions docfx_yaml/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,21 @@
from .monkeypatch import patch_docfields


class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'

try:
from conf import *
except ImportError:
print(bcolors.FAIL + 'can not import conf.py! you should have a conf.py in working project folder' + bcolors.ENDC)

METHOD = 'method'
FUNCTION = 'function'
MODULE = 'module'
Expand Down Expand Up @@ -142,6 +157,14 @@ def _create_datam(app, cls, module, name, _type, obj, lines=None):
# Make relative
path = path.replace('/', '', 1)
start_line = inspect.getsourcelines(obj)[1]

# append relative path defined in conf.py (in case of "binding python" project)
try:
source_prefix # does source_prefix exist in the current namespace
path = source_prefix + path
except NameError:
print("no source_prefix defined")

except (TypeError, OSError):
print("Can't inspect type {}: {}".format(type(obj), name))
path = None
Expand Down

0 comments on commit dda942a

Please sign in to comment.