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 #72 from docascode/yitian/fix-28725
Browse files Browse the repository at this point in the history
fix project name in toc not clickable.
  • Loading branch information
killa1218 committed Jul 16, 2018
2 parents 928241d + 13a4017 commit a30271a
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 2 deletions.
27 changes: 27 additions & 0 deletions debug.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import os
import shutil
import unittest
from contextlib import contextmanager
from sphinx.application import Sphinx

@contextmanager
def sphinx_build(test_dir):
os.chdir('tests/{0}'.format(test_dir))

try:
app = Sphinx(
srcdir='.',
confdir='.',
outdir='_build/yaml',
doctreedir='_build/.doctrees',
buildername='html',
)
app.build(force_all=True)
yield
finally:
# shutil.rmtree('_build')
os.chdir('../..')

if __name__ == '__main__':
with sphinx_build('pyexample'):
print('Debug finished.')
31 changes: 30 additions & 1 deletion docfx_yaml/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,14 +626,43 @@ def convert_module_to_package_if_needed(obj):
writable.write(
dump(
[{
'uid': app.config.project,
'uid': 'project-' + app.config.project,
'name': app.config.project,
'items': toc_yaml
}],
default_flow_style=False,
)
)

index_file = os.path.join(normalized_outdir, 'index.yml')
index_children = []
index_references = []
for item in toc_yaml:
index_children.append(item.get('uid', ''))
index_references.append({
'uid': item.get('uid', ''),
'name': item.get('name', ''),
'fullname': item.get('name', ''),
'isExternal': False
})
with open(index_file, 'w') as index_file_obj:
index_file_obj.write('### YamlMime:UniversalReference\n')
dump(
{
'items': [{
'uid': 'project-' + app.config.project,
'name': app.config.project,
'langs': ['python'],
'type': 'package',
'summary': '',
'children': index_children
}],
'references': index_references
},
index_file_obj,
default_flow_style=False
)


def missing_reference(app, env, node, contnode):
reftarget = ''
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.38',
version='1.2.39',
author='Eric Holscher',
author_email='eric@ericholscher.com',
url='https://github.com/ericholscher/sphinx-docfx-yaml',
Expand Down

0 comments on commit a30271a

Please sign in to comment.