Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Aug 2, 2018
0 parents commit 93da82a
Show file tree
Hide file tree
Showing 13 changed files with 235 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
root = true

[*]
charset = utf-8
# end_of_line = git
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.py]
indent_size = 4
indent_style = space

[*.md]
trim_trailing_whitespace = false
50 changes: 50 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@

# Created by https://www.gitignore.io/api/windows,osx,linux,git

### OSX ###
*.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk


### Linux ###
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*


### Git ###
*.orig

### Custom ###
deps/
wiki/
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Change Log
21 changes: 21 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Contributing
Contributions are welcome, and they are greatly appreciated!

Every little bit helps, and credit will always be given.

## Types of Contributions

### Bug Reports, Feature Requests, and Feedback
Create a [new project issue][1]! Try to be as descriptive as possible.

### Bug Fixes, New Features and Documentation
Create a [new merge/pull request][2]! Make sure to follow the guidelines.

## Merge/Pull Request Guidelines
Make sure to have atomic commits and contextual commit messages!

[Check out this awesome blog post by Chris Beams for more information.][3]

[1]: https://gitlab.com/shellm/doc/issues/new
[2]: https://github.com/shellm/doc/merge_requests/new
[3]: http://chris.beams.io/posts/git-commit/
15 changes: 15 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ISC License

Copyright (c) 2018, Timothée Mazzucotelli

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
39 changes: 39 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
.PHONY: rmdoc

BINDIR := bin
LIBDIR := lib
MANDIR := man
WIKIDIR := wiki

MANPAGES := $(addprefix $(MANDIR)/,doc.1 doc.sh.3)
WIKIPAGES := $(addprefix $(WIKIDIR)/,bin/doc.md lib/doc.sh.md)

ifeq ($(PREFIX), )
PREFIX := /usr/local
endif

all : doc

install :
@./install.sh $(PREFIX)

$(MANDIR)/%.1 : $(BINDIR)/%
@shellman --format man $< > $@

$(MANDIR)/%.sh.3 : $(LIBDIR)/%.sh
@shellman --format man $< > $@

$(WIKIDIR)/bin/%.md : $(BINDIR)/%
@shellman --format markdown $< > $@

$(WIKIDIR)/lib/%.sh.md : $(LIBDIR)/%.sh
@shellman --format markdown $< > $@

man : $(MANPAGES)

wiki : $(WIKIPAGES)

doc : man wiki

rmdoc:
@rm man/* wiki/bin/* wiki/lib/*
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# doc
Documentation for your shell scripts!

- Authors: https://gitlab.com/shellm/doc/AUTHORS.md
- Changelog: https://gitlab.com/shellm/doc/CHANGELOG.md
- Contributing: https://gitlab.com/shellm/doc/CONTRIBUTING.md
- Documentation: https://gitlab.com/shellm/doc/wiki
- License: ISC - https://gitlab.com/shellm/doc/LICENSE

## Installation
Installation with [basher](https://github.com/basherpm/basher):
```bash
basher install shellm/doc
```

Installation from source:
```bash
git clone https://gitlab.com/shellm/doc
cd doc
sudo ./install.sh
```

## Usage
Command-line:
```
doc -h
```

As a library:
```bash
# with basher's include
include shellm/doc lib/doc.sh
# with shellm's include
shellm-include shellm/doc lib/doc.sh
```
54 changes: 54 additions & 0 deletions bin/doc
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env bash

## \brief Documentation for your shell scripts!

shellm-source shellm/doc

if [ $# -eq 0 ]; then
doc --print-usage "$0"
exit 1
fi

__doc_get() {
local re='^[[:space:]]*##[[:space:]]*[@\]'"$1"'[[:space:]]'
grep "${re}" "$2" | expand | sed 's/'"${re}"'*//'
# shellcheck disable=SC2086
return ${PIPESTATUS[0]}
}

main() {
while [ $# -ne 0 ]; do
case "$1" in
## \option -h, --help
## Print this help and exit.
-h|--help) doc --print-help "$0"; exit 0 ;;

## \option --print-help SCRIPT
## Print help for the given script.
--print-help)
if ! command -v shellman &>/dev/null; then
if ! man "$(basename "$1")"; then
echo "doc: please install shellman dependency with pip install shellman" >&2
return 1
fi
return 0
fi
shellman "$1"
;;

## \option --print-usage SCRIPT
## Print usage for the given script.
--print-usage)
usages="$(__doc_get usage "$1")"
echo "usage: $(echo "${usages}" | head -n1)"
echo "${usages}" | tail -n+2 | while read -r line; do
echo " ${line}"
done
;;
esac
shift
done
}

## \usage doc [-h]
main "$@"
Empty file added cmp/doc.completion.bash
Empty file.
Empty file added cmp/doc.completion.zsh
Empty file.
Empty file added man/doc.1
Empty file.
Empty file added man/doc.sh.3
Empty file.
4 changes: 4 additions & 0 deletions package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
BINS="bin/doc"
DEPS="gitlab.com/shellm/core"
BASH_COMPLETIONS="cmp/doc.completion.bash"
ZSH_COMPLETIONS="cmp/doc.completion.zsh"

0 comments on commit 93da82a

Please sign in to comment.