OSDN Git Service

Improve api docs
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Thu, 6 Jun 2013 10:19:23 +0000 (13:19 +0300)
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Thu, 6 Jun 2013 10:19:23 +0000 (13:19 +0300)
app/controllers/help_controller.rb
app/views/help/_api_layout.html.haml [new file with mode: 0644]
app/views/help/api.html.haml
config/routes.rb
doc/api/deploy_keys.md [new file with mode: 0644]
doc/api/project_snippets.md [moved from doc/api/snippets.md with 100% similarity]
doc/api/projects.md

index b22280d..2958367 100644 (file)
@@ -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 (file)
index 0000000..2f649a5
--- /dev/null
@@ -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
index 0c502ad..b6ad5e1 100644 (file)
-= 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"))
index 0a1e537..c555cd0 100644 (file)
@@ -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 (file)
index 0000000..5a39409
--- /dev/null
@@ -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
+
index d3d15ab..7818d80 100644 (file)
@@ -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
-