Last active
May 24, 2017 01:52
-
-
Save jnothman/3f164a9f8f766009d29a95ab473ff972 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from doc2dash.parsers.intersphinx import (InterSphinxParser, | |
inv_entry_to_path, | |
ParserEntry) | |
import doc2dash.parsers | |
class InterSphinxWithUserGuide(InterSphinxParser): | |
def convert_type(self, inv_type): | |
if inv_type == 'std:doc': # sphinx type | |
return 'Guide' # Dash type | |
return super(InterSphinxWithUserGuide, self).convert_type(inv_type) | |
def create_entry(self, dash_type, key, inv_entry): | |
if dash_type == 'Guide': | |
path_str = inv_entry_to_path(inv_entry) | |
return ParserEntry(name=inv_entry[3], type=dash_type, | |
path=path_str) | |
return super(InterSphinxWithUserGuide, | |
self).create_entry(dash_type, key, inv_entry) | |
class ScikitLearnParser(InterSphinxWithUserGuide): | |
def convert_type(self, inv_type): | |
if inv_type.endswith(':attribute'): | |
# Hide attributes in scikit-learn | |
return | |
return super(ScikitLearnParser, self).convert_type(inv_type) | |
def create_entry(self, dash_type, key, inv_entry): | |
if dash_type == 'Guide': | |
path_str = inv_entry_to_path(inv_entry) | |
name = inv_entry[3] | |
if name == '<no title>': | |
return | |
if inv_entry[2].startswith('modules/generated/'): | |
return | |
if inv_entry[2].startswith('auto_examples/'): | |
name = 'Example: ' + name | |
if inv_entry[2].startswith('tutorial/'): | |
name = 'Tutorial: ' + name | |
return ParserEntry(name=name, type=dash_type, | |
path=path_str) | |
return super(ScikitLearnParser, | |
self).create_entry(dash_type, key, inv_entry) | |
doc2dash.parsers.DOCTYPES = [InterSphinxWithUserGuide] | |
if __name__ == '__main__': | |
import doc2dash.__main__ | |
doc2dash.__main__.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment