Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2291)

Side by Side Diff: bin/lint-yuidoc

Issue 6811062: CSS styling for buttons
Patch Set: CSS styling for buttons Created 12 years, 5 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 import os 3 import os
4 import os.path 4 import os.path
5 import re 5 import re
6 import sys 6 import sys
7 7
8 # We don't want to build or integrate with a full JS parser; fortunately we 8 # We don't want to build or integrate with a full JS parser; fortunately we
9 # comply with our coding style well enough that we can pick out the non-trivial 9 # comply with our coding style well enough that we can pick out the non-trivial
10 # function definitions because they are on a line by themselves and are either 10 # function definitions because they are on a line by themselves and are either
(...skipping 10 matching lines...) Expand all
21 name = filter(bool, match.groups())[0] 21 name = filter(bool, match.groups())[0]
22 yield name, line_number 22 yield name, line_number
23 23
24 24
25 def find_docs(function_name, line_number, boundry, source): 25 def find_docs(function_name, line_number, boundry, source):
26 # Walk backwards from the function declaration to find some yuidoc. If we 26 # Walk backwards from the function declaration to find some yuidoc. If we
27 # hit the previous function declaration ("boundry") before finding one, 27 # hit the previous function declaration ("boundry") before finding one,
28 # then there is none. 28 # then there is none.
29 in_comment = False 29 in_comment = False
30 for current_line_number in range(line_number-1, boundry, -1): 30 for current_line_number in range(line_number-1, boundry, -1):
31 source_line = source[current_line_number] 31 source_line = source[current_line_number]
32 if source_line.strip().startswith('*/'): 32 if source_line.strip().startswith('*/'):
33 in_comment = True 33 in_comment = True
34 elif source_line.strip().startswith('/*'): 34 elif source_line.strip().startswith('/*'):
35 in_comment = False 35 in_comment = False
36 # If we enter or exit a block while scanning backwards without finding 36 # If we enter or exit a block while scanning backwards without finding
37 # documentation, then there is none to be found. 37 # documentation, then there is none to be found.
38 if not in_comment and ('{' in source_line or '}' in source_line): 38 if not in_comment and ('{' in source_line or '}' in source_line):
39 return False 39 return False
40 # If we find a documentation block, tell the caller that we did. 40 # If we find a documentation block, tell the caller that we did.
41 if '/**' in source[current_line_number]: 41 if '/**' in source[current_line_number]:
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 return [i for i in seq if i != unwanted] 80 return [i for i in seq if i != unwanted]
81 81
82 82
83 def main(): 83 def main():
84 # Did we find any lint? 84 # Did we find any lint?
85 found_errors = False 85 found_errors = False
86 # All of the functions found. 86 # All of the functions found.
87 all_functions = [] 87 all_functions = []
88 for root, dirs, files in os.walk('app'): 88 for root, dirs, files in os.walk('app'):
89 # Ignore any asset directories. 89 # Ignore any asset directories.
90 dirs[:] = remove('assets', dirs) 90 dirs[:] = remove('assets', dirs)
gary.poster 2012/11/01 15:06:30 I'd remove the function call and do it locally, on
bac 2012/11/02 09:06:57 Done.
91 # Ignore the template.js file. 91 # Ignore the template.js file.
92 files[:] = remove('templates.js', files) 92 files[:] = remove('templates.js', files)
93 files = filter(lambda x: x.endswith('.js'), files)
gary.poster 2012/11/01 15:06:30 Without much excitement, I suggest you remove the
bac 2012/11/02 09:06:57 Done.
93 94
94 with open('undocumented') as f: 95 with open('undocumented') as f:
95 undocumented = [tuple(line.split()) for line in f.readlines()] 96 undocumented = [tuple(line.split()) for line in f.readlines()]
96 for file_name in [os.path.join(root, name) for name in files]: 97 for file_name in [os.path.join(root, name) for name in files]:
97 functions, missing_documentation, falsely_undocumented = ( 98 functions, missing_documentation, falsely_undocumented = (
98 check_file(file_name, undocumented)) 99 check_file(file_name, undocumented))
99 all_functions.extend(functions) 100 all_functions.extend(functions)
100 for code_location in missing_documentation: 101 for code_location in missing_documentation:
101 print code_location, 'missing yuidoc' 102 print code_location, 'missing yuidoc'
102 found_errors = True 103 found_errors = True
(...skipping 12 matching lines...) Expand all
115 print 'Backlog of undocumented functions:', len(undocumented) 116 print 'Backlog of undocumented functions:', len(undocumented)
116 print 'Please do your part to drive the above to zero by documenting ' 117 print 'Please do your part to drive the above to zero by documenting '
117 print 'functions listed in the "undocumented" file and removing their ' 118 print 'functions listed in the "undocumented" file and removing their '
118 print 'entries therein. The people of the future thank you.' 119 print 'entries therein. The people of the future thank you.'
119 120
120 return int(found_errors) 121 return int(found_errors)
121 122
122 123
123 if __name__ == '__main__': 124 if __name__ == '__main__':
124 sys.exit(main()) 125 sys.exit(main())
OLDNEW
« no previous file with comments | « [revision details] ('k') | lib/views/stylesheet.less » ('j') | lib/views/stylesheet.less » ('J')

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b