Skip to content

Commit eebf6e1

Browse files
committed
fixed reading of top level classes
1 parent 712630c commit eebf6e1

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

crawl.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
EXCLUDE_INHERITED = True
1212
EXCLUDE_INHERITED_STATIC = True
1313

14-
URL_RUNTIME_CLASSES = 'http://docs.unity3d.com/Documentation/ScriptReference/20_class_hierarchy.html'
15-
URL_RUNTIME_ATTRIBUTES = 'http://docs.unity3d.com/Documentation/ScriptReference/20_class_hierarchy.Attributes.html'
16-
URL_RUNTIME_ENUMERATIONS = 'http://docs.unity3d.com/Documentation/ScriptReference/20_class_hierarchy.Enumerations.html'
17-
URL_EDITOR_CLASSES = 'http://docs.unity3d.com/Documentation/ScriptReference/20_class_hierarchy.Editor_Classes.html'
18-
URL_EDITOR_ATTRIBUTES = 'http://docs.unity3d.com/Documentation/ScriptReference/20_class_hierarchy.Editor_Attributes.html'
19-
URL_EDITOR_ENUMERATIONS = 'http://docs.unity3d.com/Documentation/ScriptReference/20_class_hierarchy.Editor_Enumerations.html'
14+
CLASS_RUNTIME_CLASSES = 'classRuntime'
15+
CLASS_RUNTIME_ATTRIBUTES = 'attrRuntime'
16+
CLASS_RUNTIME_ENUMERATIONS = 'enumRuntime'
17+
CLASS_EDITOR_CLASSES = 'classEditor'
18+
CLASS_EDITOR_ATTRIBUTES = 'attrEditor'
19+
CLASS_EDITOR_ENUMERATIONS = 'enumEditor'
2020

2121
BASE_URL = 'http://docs.unity3d.com/Documentation/ScriptReference/'
2222

@@ -67,10 +67,10 @@
6767
def getPage(url):
6868
return webGetter.getUrl(url)
6969

70-
def readTopList(url):
71-
page = html.fromstring(getPage(url))
70+
def readTopList(domClass):
71+
page = html.fromstring(getPage(BASE_URL))
7272
classes = {}
73-
for link in page.xpath('//a[@class="classlink"]'):
73+
for link in page.xpath('//li[@class="' + domClass + '"]/a'):
7474
className = link.text.strip()
7575
classUrl = link.get('href')
7676
classes[className] = readClass(BASE_URL + classUrl, className)
@@ -150,11 +150,11 @@ def parseParam(param):
150150

151151

152152
data = {}
153-
data['Runtime Classes'] = readTopList(URL_RUNTIME_CLASSES)
154-
data['Runtime Attributes'] = readTopList(URL_RUNTIME_ATTRIBUTES)
155-
data['Runtime Enumerations'] = readTopList(URL_RUNTIME_ENUMERATIONS)
156-
data['Editor Classes'] = readTopList(URL_EDITOR_CLASSES)
157-
data['Editor Attributes'] = readTopList(URL_EDITOR_ATTRIBUTES)
158-
data['Editor Enumerations'] = readTopList(URL_EDITOR_ENUMERATIONS)
153+
data['Runtime Classes'] = readTopList(CLASS_RUNTIME_CLASSES)
154+
data['Runtime Attributes'] = readTopList(CLASS_RUNTIME_ATTRIBUTES)
155+
data['Runtime Enumerations'] = readTopList(CLASS_RUNTIME_ENUMERATIONS)
156+
data['Editor Classes'] = readTopList(CLASS_EDITOR_CLASSES)
157+
data['Editor Attributes'] = readTopList(CLASS_EDITOR_ATTRIBUTES)
158+
data['Editor Enumerations'] = readTopList(CLASS_EDITOR_ENUMERATIONS)
159159

160160
pickle.dump(data, open(OUTPUT_FILENAME, 'wb'), pickle.HIGHEST_PROTOCOL)

0 commit comments

Comments
 (0)