-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Normalize directories and generate redirections (#315)
Some structure changes: - `api/api-reference/controller-xxx` => `api/controllers/xxx` - `guide/guides/xxx` => `guides/xxx` - `plugins/plugins/xxx` => split entre `plugins/guides/xxx` et `plugins/essentials` - `protocols/protocols/xxx` => split entre `protocols/api/xxx`, `protocols/essentials/xxx` et `protocols/native-protocols/xxx` JS 5, PHP 3 and Android 3 SDK are now on the same structures as the other SDK (`core-classes`, `essentials`) The file [redirections.yml](https://github.com/kuzzleio/documentation/blob/d237e73ee394b23ccfaf34ce7bf36c1078a402ae/redirections.yml) contain all the redirection from the old v2 pages to new v3 pages. Paths like `api/1/controller-document` are root path, redirection for files in subfolders has to be handled. The script `check_redirections.rb` checks that every page from v2 has a redirection in v3. I also replace every links after renaming/moving directories. (Maybe I miss some links but Vuepress have a dead link checker)
- Loading branch information
Showing
2,353 changed files
with
1,712 additions
and
1,176 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
require 'yaml' | ||
require 'json' | ||
|
||
def each_dir(start, &block) | ||
directories = Dir["#{start}/*"] | ||
|
||
directories.each do |path| | ||
if File.file?(path) | ||
block.call(path) | ||
else | ||
each_dir(path, &block) | ||
end | ||
end | ||
end | ||
|
||
redirections = YAML.load_file('./redirections.yml') | ||
|
||
v2_redir = [] | ||
v2_pages = [] | ||
|
||
redirections['redirections'].each do |redirection| | ||
each_dir("../documentation-v2/src/#{redirection['from']}") do |file| | ||
v2_redir << file.gsub('../documentation-v2/', '') | ||
end | ||
end | ||
|
||
each_dir("../documentation-v2/src/") do |file| | ||
next unless file.end_with?('.md') | ||
v2_pages << file.gsub('../documentation-v2/', '').gsub(/\/\//, '/') | ||
end | ||
|
||
v2_redir.uniq! | ||
v2_pages.uniq! | ||
missing_redirections = v2_pages - v2_redir | ||
|
||
puts "#{v2_redir.count} redirection from v2 to v3" | ||
puts "#{v2_pages.count} pages for v2" | ||
puts "#{missing_redirections.count} missing redirections" | ||
|
||
if missing_redirections.any? | ||
File.write('./missing-redirections.json', JSON.pretty_generate(missing_redirections)) | ||
end |
Oops, something went wrong.