File tree Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -50,4 +50,34 @@ task :validate_links => [:build] do
50
50
sh ( 'bundle exec htmlproofer _site --assume-extension --disable-external --empty-alt-ignore --allow-hash-href --url-swap "^/docs/:/"' )
51
51
end
52
52
53
- task :validate => [ :validate_kit_versions , :validate_links ]
53
+ task :validate_sidebar_tree do # => [:build] do
54
+ # There are lots of things which this could validate, however we assume that
55
+ # most changes will be eyeballed by a human. We therefore just check the most
56
+ # nuanced case -- that the url must be an exact match for its target page.
57
+
58
+ def check_url ( url )
59
+ if url . end_with? "/" then
60
+ raise "Imprecise target url '#{ url } ' in sidebar (did you mean '#{ url [ ..-2 ] } '?)\n \n " unless File . directory? ( "_site#{ url } " )
61
+ else
62
+ raise "Imprecise target url '#{ url } ' in sidebar (did you mean '#{ url } /'?)\n \n " unless File . file? ( "_site#{ url } .html" )
63
+ end
64
+ end
65
+
66
+ def check_nodes ( node )
67
+ check_url ( node [ 'url' ] )
68
+ if node [ 'tree' ] then
69
+ node [ 'tree' ] . each do |x |
70
+ check_nodes ( x )
71
+ end
72
+ end
73
+ end
74
+
75
+ data = YAML . load_file ( '_data/sidebar_tree.yaml' )
76
+ data [ 'tree' ] . each do |x |
77
+ check_nodes ( x )
78
+ end
79
+
80
+ puts "Sidebar links validated successfully"
81
+ end
82
+
83
+ task :validate => [ :validate_kit_versions , :validate_links , :validate_sidebar_tree ]
Original file line number Diff line number Diff line change 63
63
tree :
64
64
- url : /programming/sr/vision/markers
65
65
title : Markers
66
- - url : /programming/editors
66
+ - url : /programming/editors/
67
67
title : Code Editors
68
68
tree :
69
69
- url : /programming/editors/vscode
You can’t perform that action at this time.
0 commit comments