Skip to content

Commit

Permalink
Merge pull request #16 from ritikbheda/lab-7
Browse files Browse the repository at this point in the history
  • Loading branch information
ritikbheda authored Nov 7, 2021
2 parents d8e515d + db60505 commit 1cb27f0
Show file tree
Hide file tree
Showing 14 changed files with 3,486 additions and 332 deletions.
8 changes: 8 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
dlist
node_modules
Sherlock-Holmes-Selected-Stories
.eslintrc.json
LICENSE
README.md
package.json
package-lock.json
16 changes: 16 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"env": {
"browser": true,
"commonjs": true,
"es2021": true,
"node": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 13
},
"rules": {
"no-console": ["warn"],
"no-useless-escape": ["off"]
}
}
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx prettier --write .
1 change: 1 addition & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
10 changes: 10 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"editor.insertSpaces": true,
"editor.tabSize": 2,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll": true
},
"files.eol": "\n",
"files.insertFinalNewline": true
}
23 changes: 23 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Contributing

Suggestions and pull requests are highly encouraged! Have a look at the [open issues](https://github.com/ritikbheda/commandline-ssg/issues).

## Requirements

[Node.js](https://nodejs.org/en/download/) version 16 or later is required.

## Workflow

First clone:

```sh
git clone https://github.com/ritikbheda/commandline-ssg
cd commandline-ssg
npm install
```

When working on the tool, use this to link your command for development:

```sh
npm link
```
60 changes: 41 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,73 +1,94 @@
# Commandline-SSG

Commandline Static Site Generating tool that helps you produce `.html` from `.txt` or `.md` files

## Features

The tool is before its first release but comes up with these features already:
* accept `.txt` or `.md` file to generate a `.html` file
* accept folders to generate `.html` files from `.txt` and `.md` files
* goes through all the child directories of the input folder to generate the desired files
* output folder can be externally provided to get the generated files at desired location. if not provided, the output is generated in a folder set as default output folder
* stylesheet can be externally provided in either link form or file form to add style to the webpages. If not provided, the no stylesheet is added to the webpages
* detects title and paragraph of the text file to give accurate tags in the webpage and sets title to the webpage
* if a folder is provided, a new file called `index.html` is generated which contains link to all the files just generated
* program exits with code 1 if something unexpected happens; if everything is working it exits with code 0
* can generate document for any language under [MDN WebDocs](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang)

- accept `.txt` or `.md` file to generate a `.html` file
- accept folders to generate `.html` files from `.txt` and `.md` files
- goes through all the child directories of the input folder to generate the desired files
- output folder can be externally provided to get the generated files at desired location. if not provided, the output is generated in a folder set as default output folder
- stylesheet can be externally provided in either link form or file form to add style to the webpages. If not provided, the no stylesheet is added to the webpages
- detects title and paragraph of the text file to give accurate tags in the webpage and sets title to the webpage
- if a folder is provided, a new file called `index.html` is generated which contains link to all the files just generated
- program exits with code 1 if something unexpected happens; if everything is working it exits with code 0
- can generate document for any language under [MDN WebDocs](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang)

## Usage

### Options
Option | Function
------------ | -------------
-h, --help | shows all the options currently active
-v, --version | output the version number
-i, --input \<type> | takes input of the file/folder
-o, --output \<type> | takes destination folder location
-s, --stylesheet \<type\> | takes any stylesheet that needs to be added to the html
-c, --config \<type> | takes a JSON file with options

| Option | Function |
| ------------------------- | ------------------------------------------------------- |
| -h, --help | shows all the options currently active |
| -v, --version | output the version number |
| -i, --input \<type> | takes input of the file/folder |
| -o, --output \<type> | takes destination folder location |
| -s, --stylesheet \<type\> | takes any stylesheet that needs to be added to the html |
| -c, --config \<type> | takes a JSON file with options |

## Options

### Help

This option shows all the currently available options that can be used. It can be used in two ways `-h` or `--help`.<br>
Example:
> $ commandline-ssg -h

> $ commandline-ssg -h
### Version

This option shows the current version of the tool. It can be used in two ways `-v` or `--version`. <br>
Example:

> $ commandline-ssg -v
### Input

This option takes in the file/folder that needs to be converted to generate the static site. It converts `.txt` file to `.html` file. It can be used in two ways, `-i` or `--input`.<br>
Example:<br>
If the input element is a file

> $ commandline-ssg -i foo.txt
If the input element is a folder

> $ commandline-ssg -i folder
### Output

This option takes in the folder name where the user wants the final generated file to be. If this option is not provided, its default value `dist` is set for the folder output. It can be used in two ways, `-o` or `--output`.<br>
Example:

> $ commandline-ssg -i foo.txt -o newDist
### Stylesheet

This option takes in the stylesheet that adds style to each html file generated. It can be passed as either link or file. If it is not provided, no stylesheet is added to the webpages. It can be used in two ways, `-s` or `--stylesheet`.<br>
Example:

> $ commandline-ssg -i foo.txt -s https://cdnjs.cloudflare.com/ajax/libs/tufte-css/1.8.0/tufte.min.css
### Config

This option reads a given JSON file for the above options and applies the options to the resulting HTML. This will overwrite other commandline argument options. If an option is not provided in the JSON it will result to the default value. It can be used in two ways, `-c` or `--config`.<br>
Example:

> $ commandline-ssg -c config.json
## Sample Use

For instance, to generate html from a folder, `TextFolder`, in the project root directory in a new folder `HTMLFolder`, and add `https://cdnjs.cloudflare.com/ajax/libs/tufte-css/1.8.0/tufte.min.css` URL stylesheet, we can write the following command:

> $ commandline-ssg -i TextFolder -o HTMLFolder -s https://cdnjs.cloudflare.com/ajax/libs/tufte-css/1.8.0/tufte.min.css
It will do the following:<br>
If the TextFolder has one file foo.txt with these text

##### ./TextFolder/foo.txt

```
A Smart title
Expand All @@ -80,6 +101,7 @@ Another short paragraph.
a foo.html file will be generated in the HTMLFolder with the https://cdnjs.cloudflare.com/ajax/libs/tufte-css/1.8.0/tufte.min.css stylesheet.

##### ./HTMLFolder/foo.html

```
<!doctype html>
<html lang="en">
Expand All @@ -97,7 +119,7 @@ a foo.html file will be generated in the HTMLFolder with the https://cdnjs.cloud

## Keywords

**commandline-ssg** **cli**
**commandline-ssg** **cli**

## Authors

Expand Down
Loading

0 comments on commit 1cb27f0

Please sign in to comment.