diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-06-06 14:19:23 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-06-06 14:19:23 +0400 |
commit | 68d146b4a692357354e25d0c0f93edf861b37e8c (patch) | |
tree | e2dc8505f4f61c302037cceee093f11c3205ec6e | |
parent | b05600f28b39b3bf8f469ca7b293117c65217762 (diff) |
Improve api docs
-rw-r--r-- | app/controllers/help_controller.rb | 11 | ||||
-rw-r--r-- | app/views/help/_api_layout.html.haml | 13 | ||||
-rw-r--r-- | app/views/help/api.html.haml | 127 | ||||
-rw-r--r-- | config/routes.rb | 1 | ||||
-rw-r--r-- | doc/api/deploy_keys.md | 87 | ||||
-rw-r--r-- | doc/api/project_snippets.md (renamed from doc/api/snippets.md) | 0 | ||||
-rw-r--r-- | doc/api/projects.md | 123 |
7 files changed, 125 insertions, 237 deletions
diff --git a/app/controllers/help_controller.rb b/app/controllers/help_controller.rb index b22280d2fd2..2958367e0f8 100644 --- a/app/controllers/help_controller.rb +++ b/app/controllers/help_controller.rb @@ -1,4 +1,15 @@ class HelpController < ApplicationController def index end + + def api + @category = params[:category] + @category = "README" if @category.blank? + + if File.exists?(Rails.root.join('doc', 'api', @category + '.md')) + render 'api' + else + not_found! + end + end end diff --git a/app/views/help/_api_layout.html.haml b/app/views/help/_api_layout.html.haml new file mode 100644 index 00000000000..2f649a509a5 --- /dev/null +++ b/app/views/help/_api_layout.html.haml @@ -0,0 +1,13 @@ +.row + .span3 + = link_to help_path, class: 'btn append-bottom-20 btn-small' do + %i.icon-angle-left + Back to help + %br + %ul.nav.nav-pills.nav-stacked + - %w(README projects project_snippets repositories deploy_keys users session issues milestones notes system_hooks).each do |file| + %li{class: file == @category ? 'active' : nil} + = link_to file.titleize, help_api_file_path(file) + + .span9.pull-right + = yield diff --git a/app/views/help/api.html.haml b/app/views/help/api.html.haml index 0c502ada8fa..b6ad5e14fc3 100644 --- a/app/views/help/api.html.haml +++ b/app/views/help/api.html.haml @@ -1,116 +1,15 @@ -= render layout: 'help/layout' do - %h3.page_title API += render layout: 'help/api_layout' do + %h3.page_title + %span.light API + %span + \/ + = @category.titleize %br - %ul.nav.nav-tabs.log-tabs.nav-small-tabs - %li.active - = link_to "README", "#README", 'data-toggle' => 'tab' - %li - = link_to "Projects", "#projects", 'data-toggle' => 'tab' - %li - = link_to "Snippets", "#snippets", 'data-toggle' => 'tab' - %li - = link_to "Repositories", "#repositories", 'data-toggle' => 'tab' - %li - = link_to "Users", "#users", 'data-toggle' => 'tab' - %li - = link_to "Session", "#session", 'data-toggle' => 'tab' - %li - = link_to "Issues", "#issues", 'data-toggle' => 'tab' - %li - = link_to "Milestones", "#milestones", 'data-toggle' => 'tab' - %li - = link_to "Notes", "#notes", 'data-toggle' => 'tab' - %li - = link_to "System Hooks", "#system_hooks", 'data-toggle' => 'tab' - - .tab-content - .tab-pane.active#README - .file_holder - .file_title - %i.icon-file - README - .file_content.wiki - = preserve do - = markdown File.read(Rails.root.join("doc", "api", "README.md")) - - .tab-pane#projects - .file_holder - .file_title - %i.icon-file - Projects - .file_content.wiki - = preserve do - = markdown File.read(Rails.root.join("doc", "api", "projects.md")) - - .tab-pane#snippets - .file_holder - .file_title - %i.icon-file - Projects Snippets - .file_content.wiki - = preserve do - = markdown File.read(Rails.root.join("doc", "api", "snippets.md")) - - .tab-pane#repositories - .file_holder - .file_title - %i.icon-file - Projects - .file_content.wiki - = preserve do - = markdown File.read(Rails.root.join("doc", "api", "repositories.md")) - - .tab-pane#users - .file_holder - .file_title - %i.icon-file - Users - .file_content.wiki - = preserve do - = markdown File.read(Rails.root.join("doc", "api", "users.md")) - - .tab-pane#session - .file_holder - .file_title - %i.icon-file - Session - .file_content.wiki - = preserve do - = markdown File.read(Rails.root.join("doc", "api", "session.md")) - - .tab-pane#issues - .file_holder - .file_title - %i.icon-file - Issues - .file_content.wiki - = preserve do - = markdown File.read(Rails.root.join("doc", "api", "issues.md")) - - .tab-pane#milestones - .file_holder - .file_title - %i.icon-file - Milestones - .file_content.wiki - = preserve do - = markdown File.read(Rails.root.join("doc", "api", "milestones.md")) - - .tab-pane#notes - .file_holder - .file_title - %i.icon-file - Notes - .file_content.wiki - = preserve do - = markdown File.read(Rails.root.join("doc", "api", "notes.md")) - - .tab-pane#system_hooks - .file_holder - .file_title - %i.icon-file - System Hooks - .file_content.wiki - = preserve do - = markdown File.read(Rails.root.join("doc", "api", "system_hooks.md")) + .file_holder + .file_title + %i.icon-file + = @category + .file_content.wiki + = preserve do + = markdown File.read(Rails.root.join("doc", "api", "#{@category}.md")) diff --git a/config/routes.rb b/config/routes.rb index 0a1e537412c..c555cd0b361 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -29,6 +29,7 @@ Gitlab::Application.routes.draw do # get 'help' => 'help#index' get 'help/api' => 'help#api' + get 'help/api/:category' => 'help#api', as: 'help_api_file' get 'help/markdown' => 'help#markdown' get 'help/permissions' => 'help#permissions' get 'help/public_access' => 'help#public_access' diff --git a/doc/api/deploy_keys.md b/doc/api/deploy_keys.md new file mode 100644 index 00000000000..5a394094fe6 --- /dev/null +++ b/doc/api/deploy_keys.md @@ -0,0 +1,87 @@ +## Deploy Keys + +### List deploy keys + +Get a list of a project's deploy keys. + +``` +GET /projects/:id/keys +``` + +Parameters: + ++ `id` (required) - The ID of the project + +```json +[ + { + "id": 1, + "title" : "Public key" + "key": "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4 + 596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4 + soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=", + }, + { + "id": 3, + "title" : "Another Public key" + "key": "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4 + 596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4 + soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=" + } +] +``` + + +### Single deploy key + +Get a single key. + +``` +GET /projects/:id/keys/:key_id +``` + +Parameters: + ++ `id` (required) - The ID of the project ++ `key_id` (required) - The ID of the deploy key + +```json +{ + "id": 1, + "title" : "Public key" + "key": "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4 + 596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4 + soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=" +} +``` + + +### Add deploy key + +Creates a new deploy key for a project. +If deploy key already exists in another project - it will be joined to project but only if original one was is accessible by same user + +``` +POST /projects/:id/keys +``` + +Parameters: + ++ `id` (required) - The ID of the project ++ `title` (required) - New deploy key's title ++ `key` (required) - New deploy key + + +### Delete deploy key + +Delete a deploy key from a project + +``` +DELETE /projects/:id/keys/:key_id +``` + +Parameters: + ++ `id` (required) - The ID of the project ++ `key_id` (required) - The ID of the deploy key + diff --git a/doc/api/snippets.md b/doc/api/project_snippets.md index 04ea367d518..04ea367d518 100644 --- a/doc/api/snippets.md +++ b/doc/api/project_snippets.md diff --git a/doc/api/projects.md b/doc/api/projects.md index d3d15ab4e02..7818d8071e4 100644 --- a/doc/api/projects.md +++ b/doc/api/projects.md @@ -381,126 +381,3 @@ Parameters: + `id` (required) - The ID of the project. + `branch` (required) - The name of the branch. - -### List tags - -Lists all tags of a project. - -``` -GET /projects/:id/repository/tags -``` - -Parameters: - -+ `id` (required) - The ID of the project - - -### List commits - -Lists all commits with pagination. If the optional `ref_name` name is not given the commits of -the default branch (usually master) are returned. - -``` -GET /projects/:id/repository/commits -``` - -Parameters: - -+ `id` (required) - The Id of the project -+ `ref_name` (optional) - The name of a repository branch or tag -+ `page` (optional) - The page of commits to return (`0` default) -+ `per_page` (optional) - The number of commits per page (`20` default) - -Returns values: - -+ `200 Ok` on success and a list with commits -+ `404 Not Found` if project with id or the branch with `ref_name` not found - - - -## Deploy Keys - -### List deploy keys - -Get a list of a project's deploy keys. - -``` -GET /projects/:id/keys -``` - -Parameters: - -+ `id` (required) - The ID of the project - -```json -[ - { - "id": 1, - "title" : "Public key" - "key": "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4 - 596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4 - soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=", - }, - { - "id": 3, - "title" : "Another Public key" - "key": "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4 - 596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4 - soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=" - } -] -``` - - -### Single deploy key - -Get a single key. - -``` -GET /projects/:id/keys/:key_id -``` - -Parameters: - -+ `id` (required) - The ID of the project -+ `key_id` (required) - The ID of the deploy key - -```json -{ - "id": 1, - "title" : "Public key" - "key": "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4 - 596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4 - soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=" -} -``` - - -### Add deploy key - -Creates a new deploy key for a project. - -``` -POST /projects/:id/keys -``` - -Parameters: - -+ `id` (required) - The ID of the project -+ `title` (required) - New deploy key's title -+ `key` (required) - New deploy key - - -### Delete deploy key - -Delete a deploy key from a project - -``` -DELETE /projects/:id/keys/:key_id -``` - -Parameters: - -+ `id` (required) - The ID of the project -+ `key_id` (required) - The ID of the deploy key - |