Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for typedoc ~0.22.11 and strange self-referencing variable issue #189

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ sphinx_js.egg-info/
.vscode
.DS_Store
venv
# Pyenv
.python-version
22 changes: 18 additions & 4 deletions sphinx_js/typedoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,10 @@ def _convert_node(self, node) -> Tuple[TopLevel, List[dict]]:
# many attr of Functions.
sigs = node.get('signatures')
first_sig = sigs[0] # Should always have at least one
first_sig['sources'] = node['sources']
parent = node
while 'sources' not in node and '__parent' in node:
parent = node['__parent']
Kelketek marked this conversation as resolved.
Show resolved Hide resolved
first_sig['sources'] = parent['sources']
return self._convert_node(first_sig)
elif kind in ['Call signature', 'Constructor signature']:
# This is the real meat of a function, method, or constructor.
Expand Down Expand Up @@ -244,8 +247,12 @@ def _type_name(self, type):
type_of_type = type.get('type')

if type_of_type == 'reference' and type.get('id'):
node = self._index[type['id']]
name = node['name']
try:
node = self._index[type['id']]
name = node['name']
except KeyError:
# Try to get the name directly from the type, in one last attempt.
name = type['name']
elif type_of_type == 'unknown':
if re.match(r'-?\d*(\.\d+)?', type['name']): # It's a number.
# TypeDoc apparently sticks numeric constants' values into the
Expand Down Expand Up @@ -275,10 +282,15 @@ def _type_name(self, type):
if constraint is not None:
name += ' extends ' + self._type_name(constraint)
# e.g. K += extends + keyof T
elif type_of_type == 'literal':
if type['value'] is None:
name = 'null'
else:
name = repr(type['value'])
elif type_of_type == 'reflection':
name = '<TODO: reflection>'
# test_generic_member() (currently skipped) tests this.
else:
# test_generic_member() (currently skipped) tests this.
name = '<TODO: other type>'

type_args = type.get('typeArguments')
Expand Down Expand Up @@ -328,6 +340,8 @@ def typedoc_output(abs_source_paths, sphinx_conf_dir, config_path):
with NamedTemporaryFile(mode='w+b') as temp:
command.add('--json', temp.name, *abs_source_paths)
try:
from pprint import pprint
pprint(command.make())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftover debugging code?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. Removed.

subprocess.call(command.make())
except OSError as exc:
if exc.errno == ENOENT:
Expand Down