Skip to content

Commit

Permalink
Make refactors in favor of documentation (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
itai-codefresh authored Jan 15, 2018
1 parent d4c0d3f commit 97f16bc
Show file tree
Hide file tree
Showing 103 changed files with 1,078 additions and 575 deletions.
55 changes: 55 additions & 0 deletions auto-docs/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
const fs = require('fs');
const recursive = require('recursive-readdir');
const path = require('path');
const _ = require('lodash');


recursive(path.resolve(__dirname, '../lib/interface/cli/commands'), (err, files) => {

_.forEach(files, (file) => {
if (!file.endsWith('.cmd.js')) {
return;
}

console.log(file);
const command = require(file);

// dont document beta commands currently
if (command.isBetaCommand()) {
return;
}

const docs = command.prepareDocs();

const { category } = docs;

// create a directory according to the category
const dir = path.resolve(__dirname, `../docs-template/content/${(category || 'undefined').toLowerCase()}`);
if (!fs.existsSync(dir)){
fs.mkdirSync(dir);
}

// create _index.md file if does not exist for the category
const indexFile = path.resolve(dir, '_index.md');
if (!fs.existsSync(indexFile)){
fs.writeFileSync(indexFile, `+++\ntitle = "${category}"\n+++`);
}

let finalFileString = '';

finalFileString += `${docs.header}\n\n`;
finalFileString += `### Command\n\`${docs.command}\`\n\n`;
finalFileString += `${docs.description}\n`;

if (docs.positionals.length) {
finalFileString += `### Positionals\n\nOption | Default | Description\n--------- | ----------- | -----------\n${docs.positionals}`;
}

if (docs.options.length) {
finalFileString += `### Options\n\nOption | Default | Description\n--------- | ----------- | -----------\n${docs.options}`;
}


fs.writeFileSync(path.resolve(dir, `./${docs.title}.md`), finalFileString);
});
});
51 changes: 33 additions & 18 deletions docs-template/config.toml
Original file line number Diff line number Diff line change
@@ -1,29 +1,44 @@
theme = "docuapi"
theme = "docdock"
baseurl = "http://cli.codefresh.io"
title = "Codefresh CLI Documentation"
publishDir = "../docs"
languageCode = "en-us"
DefaultContentLanguage = "en"


# Code higlighting settings
pygmentsCodefences = true
pygmentsCodeFencesGuesSsyntax = false
pygmentsOptions = ""
pygmentsStyle = "monokai"
# The monokai stylesheet is included in the base template.
pygmentsUseClasses = true
pygmentsCodeFences = true
pygmentsStyle = "monokailight"

[params]
search = true
editURL = "https://github.com/vjeantet/hugo-theme-docdock/edit/master/exampleSite/content/"
showVisitedLinks = true # default is false
themeStyle = "original" # "original" or "flex" # default "original"
themeVariant = "" # choose theme variant "green", "gold" , "gray", "blue" (default)
ordersectionsby = "weight" # ordersectionsby = "title"
disableHomeIcon = false # default is false
disableSearch = false # default is false
disableNavChevron = false # set true to hide next/prev chevron, default is false
highlightClientSide = false # set true to use highlight.pack.js instead of the default hugo chroma highlighter

# Configure the language example tabs.
[[params.language_tabs]]
key = "cli"
name = "Cli"

#Languages
[languages]
[outputs]
home = [ "HTML", "RSS", "JSON"]

[languages.en]
languageName = "English"
weight = 2

[[menu.shortcuts]]
pre = "<h3>More</h3>"
name = "<i class='fa fa-github'></i> Github repo"
identifier = "ds"
url = "https://github.com/codefresh-io/cli"
weight = 10

[[menu.shortcuts]]
name = "<i class='fa fa-camera'></i> Examples"
url = "/Examples"
weight = 11

[[menu.shortcuts]]
name = "<i class='fa fa-bookmark'></i> Codefresh Documentation"
identifier = "hugodoc"
url = "https://docs.codefresh.io"
weight = 20
62 changes: 0 additions & 62 deletions docs-template/content/Installation.md

This file was deleted.

6 changes: 6 additions & 0 deletions docs-template/content/_header.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
+++
title = "header"
description = ""
date = "2017-04-24T18:36:24+02:00"
+++
Codefresh CLI Documentation
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
+++
title = "Create authentication context"
+++

### Command
`codefresh auth create-context [name]`

Create or update an authentication context
### Positionals

Option | Default | Description
--------- | ----------- | -----------
name | default | Context name
### Options

Option | Default | Description
--------- | ----------- | -----------
--url | https://g.codefresh.io | Codefresh system custom url
--api-key | | API key
8 changes: 8 additions & 0 deletions docs-template/content/authentication/Get activated context.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
+++
title = "Get activated context"
+++

### Command
`codefresh auth current-context`

Get the current activated authentication context
8 changes: 8 additions & 0 deletions docs-template/content/authentication/Get all contexts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
+++
title = "Get all contexts"
+++

### Command
`codefresh auth get-contexts`

Get all possible authentication contexts
13 changes: 13 additions & 0 deletions docs-template/content/authentication/Set active context.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
+++
title = "Set active context"
+++

### Command
`codefresh auth use-context <name>`

Set the current active authentication context
### Positionals

Option | Default | Description
--------- | ----------- | -----------
context-name | | a context-name that exists in cfconfig file
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
---
weight: 30
title: Authentication
---

# Authentication
+++
title = "Authentication"
description = "asd"
date = "2017-04-24T18:36:24+02:00"
+++

## Basic Usage
In order to start working with the cli you will need to update the authentication configuration. <br />
Expand Down
23 changes: 23 additions & 0 deletions docs-template/content/builds/Get a single build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
+++
title = "Get a single build"
+++

### Command
`codefresh get builds [id]`

Get a specific builds or an array of builds
### Positionals

Option | Default | Description
--------- | ----------- | -----------
id | | Build id
### Options

Option | Default | Description
--------- | ----------- | -----------
--limit | 25 | Limit amount of returned results
--page | 1 | Paginated page
--status | | Filter results by statuses
--trigger | | Filter results by triggers
--pipeline-id | | Filter results by pipeline id
--pipeline-name | | Filter results by pipeline name
18 changes: 18 additions & 0 deletions docs-template/content/builds/Restart a build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
+++
title = "Restart a build"
+++

### Command
`codefresh restart <id>`

Restart a build by its id
### Positionals

Option | Default | Description
--------- | ----------- | -----------
id | | Build id
### Options

Option | Default | Description
--------- | ----------- | -----------
--detach | | Run build and print workflow ID
18 changes: 18 additions & 0 deletions docs-template/content/builds/Show logs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
+++
title = "Show logs"
+++

### Command
`codefresh logs <id>`

Show logs of a build
### Positionals

Option | Default | Description
--------- | ----------- | -----------
id | | Pipeline id
### Options

Option | Default | Description
--------- | ----------- | -----------
--f | | Continue showing build logs until it will finish
13 changes: 13 additions & 0 deletions docs-template/content/builds/Terminate a build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
+++
title = "Terminate a build"
+++

### Command
`codefresh terminate <id>`

Terminate a build by its id
### Positionals

Option | Default | Description
--------- | ----------- | -----------
id | | Build id
20 changes: 20 additions & 0 deletions docs-template/content/builds/Wait for a build condition.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
+++
title = "Wait for a build condition"
+++

### Command
`codefresh wait <id..>`

Wait until a condition will be met on a build
### Positionals

Option | Default | Description
--------- | ----------- | -----------
id | | Build id
### Options

Option | Default | Description
--------- | ----------- | -----------
--status | | Build status
--debug | | Show debug output until the condition will be met
--timeout | 30 | Define a timeout for the wait operation in minutes
3 changes: 3 additions & 0 deletions docs-template/content/builds/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
+++
title = "Builds"
+++
20 changes: 20 additions & 0 deletions docs-template/content/compositions/Create a composition.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
+++
title = "Create a composition"
+++

### Command
`codefresh create composition [name]`

Create a composition
### Positionals

Option | Default | Description
--------- | ----------- | -----------
name | | Name of composition
### Options

Option | Default | Description
--------- | ----------- | -----------
--variable | | Variables list
--advanced | | Advanced composition
--yaml | | Path to yaml file to use to create the resource
13 changes: 13 additions & 0 deletions docs-template/content/compositions/Delete a composition.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
+++
title = "Delete a composition"
+++

### Command
`codefresh delete composition [name]`

Delete a composition
### Positionals

Option | Default | Description
--------- | ----------- | -----------
name | | Composition name
Loading

0 comments on commit 97f16bc

Please sign in to comment.