development/kodespel: Added (spell-checker for source code)

Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
This commit is contained in:
B. Watson 2023-01-20 05:43:29 +00:00 committed by Willy Sudiarto Raharjo
parent 71bffab76c
commit be2d703e5c
No known key found for this signature in database
GPG Key ID: 3F617144D7238786
8 changed files with 643 additions and 0 deletions

View File

@ -0,0 +1,8 @@
kodespel (spell-checker for source code)
kodespel is a spellchecker for source code. kodespel's nifty trick
is that it knows how to split common programming identifiers like
'getAllStuff' or 'DoThingsNow' or 'num_objects' or 'HTTPResponse' into
words, feed those to ispell, and interpret ispell's output.
See also: codespell (same concept, different implementation).

View File

@ -0,0 +1,65 @@
#!/bin/sh
# Create source tarball from git repo, with generated version number.
# Takes one optional argument, which is the commit or tag to create a
# tarball of. With no arg, HEAD is used.
# Version number example: 0.0.1+20200227_ad7ec17
# Notes:
# Do not use this if you're packaging a release.
# This script doesn't need to be run as root. It does need to be able
# to write to the current directory it's run from.
# Running this script twice for the same commit will NOT give identical
# tarballs, even if the contents are identical. This is because tar
# includes the current time in a newly-created tarball (plus there may
# be other git-related reasons).
# Once you've generated a tarball, you'll still need a place to host it.
# Ask on the mailing list, if you don't have your own web server to
# play with.
## Config:
PRGNAM=kodespel
CLONE_URL=https://github.com/gward/kodespel
## End of config.
set -e
GITDIR=$( mktemp -dt $PRGNAM.git.XXXXXX )
rm -rf $GITDIR
git clone $CLONE_URL $GITDIR
CWD="$( pwd )"
cd $GITDIR
if [ "$1" != "" ]; then
git reset --hard "$1" || exit 1
fi
GIT_SHA=$( git rev-parse --short HEAD )
DATE=$( git log --date=format:%Y%m%d --format=%cd | head -1 )
VERTAG=$( git tag -l | tail -1 )
VERSION=${VERTAG}+${DATE}_${GIT_SHA}
rm -rf .git
find . -name .gitignore -print0 | xargs -0 rm -f
cd "$CWD"
rm -rf $PRGNAM-$VERSION $PRGNAM-$VERSION.tar.xz
mv $GITDIR $PRGNAM-$VERSION
tar cvfJ $PRGNAM-$VERSION.tar.xz $PRGNAM-$VERSION
echo
echo "Created tarball: $PRGNAM-$VERSION.tar.xz"
echo "VERSION=\"$VERSION\""
echo "MD5SUM=\"$( md5sum $PRGNAM-$VERSION.tar.xz | cut -d' ' -f1 )\""

View File

@ -0,0 +1,257 @@
.\" Man page generated from reStructuredText.
.
.
.nr rst2man-indent-level 0
.
.de1 rstReportMargin
\\$1 \\n[an-margin]
level \\n[rst2man-indent-level]
level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
-
\\n[rst2man-indent0]
\\n[rst2man-indent1]
\\n[rst2man-indent2]
..
.de1 INDENT
.\" .rstReportMargin pre:
. RS \\$1
. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
. nr rst2man-indent-level +1
.\" .rstReportMargin post:
..
.de UNINDENT
. RE
.\" indent \\n[an-margin]
.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
.nr rst2man-indent-level -1
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
..
.TH "KODESPEL" 1 "2023-01-16" "0.1.1+20220227_e0095c7" "SlackBuilds.org"
.SH NAME
kodespel \- spell-checker for source code
.\" RST source for kodespel(1) man page. Convert with:
.
.\" rst2man.py kodespel.rst > kodespel.1
.
.SH SYNOPSIS
.sp
kodespel [\fB\-d\fP \fIdictionary\fP] \fIfile\fP [\fIfile\fP ...]
.sp
kodespel \fB\-\-list\-dicts\fP
.SH DESCRIPTION
.sp
kodespel is a spellchecker for source code. kodespel\(aqs nifty trick
is that it knows how to split common programming identifiers like
\(aqgetAllStuff\(aq or \(aqDoThingsNow\(aq or \(aqnum_objects\(aq or \(aqHTTPResponse\(aq into
words, feed those to \fBispell\fP(1), and interpret ispell\(aqs output.
.sp
Basic usage is to run kodespel on one or more individual files
or directories:
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
kodespel foo.py main.go README.md
.ft P
.fi
.UNINDENT
.UNINDENT
.sp
kodespel uses a collection of dictionaries to spellcheck each file.
It always uses the \fBbase\fP dictionary, which is a set of words
common in source code across languages and platforms. Additionally,
there is a language\-specific dictionary for each language kodespel
knows about. Language\-specific dictionaries are automatically chosen
for you.
.sp
In this example, kodespell will spellcheck each file with:
.INDENT 0.0
.INDENT 3.5
.INDENT 0.0
.IP \(bu 2
\fBfoo.py\fP: dictionaries \fBbase\fP and \fBpython\fP
.IP \(bu 2
\fBmain.go\fP: dictionaries \fBbase\fP and \fBgo\fP
.IP \(bu 2
\fBREADME.md\fP: dictionary \fBbase\fP only (no language dictionary for Markdown)
.UNINDENT
.UNINDENT
.UNINDENT
.sp
If run on a directory, kodespel will recurse into that directory
and spellcheck every file that it recognizes:
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
kodespel src/
.ft P
.fi
.UNINDENT
.UNINDENT
.sp
will search for \fB*.py\fP, \fB*.c\fP, \fB*.h\fP, and any other
extension that kodespel has built\-in support for.
(Currently: Python, Perl, Go, C, C++, and Java).
Unsupported files are ignored, but if you pass those filenames
explicitly, they will be checked.
.INDENT 0.0
.INDENT 3.5
Note: the SlackBuilds.org package of \fBkodespel\fP includes a
\fBsbo\fP dictionary. It will only be used if you enable it
with \fB\-d sbo\fP\&.
.UNINDENT
.UNINDENT
.sp
kodespel ships with several other common dictionaries.
For example, if the program you are spellchecking uses
a lot of Unix system calls, you would add the \fBunix\fP dictionary:
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
kodespel \-d unix foo.py main.go README.md
.ft P
.fi
.UNINDENT
.UNINDENT
.sp
The \fB\-d\fP option applies to every file being checked.
.sp
To see the list of all builtin dictionaries, run:
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
kodespel \-\-list\-dicts
.ft P
.fi
.UNINDENT
.UNINDENT
.sp
Finally, you can create your own dictionaries,
and use as many of them as you like.
A dictionary is a plain text file with one word per line:
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
$ cat myproject.dict
nargs
args
.ft P
.fi
.UNINDENT
.UNINDENT
.sp
You can specify your personal dictionaries with \fB\-d\fP,
just like kodespel\(aqs builtin dictionaries:
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
kodespel \-d unix \-d myproject.dict foo.py ...
.ft P
.fi
.UNINDENT
.UNINDENT
.SH OPTIONS
.INDENT 0.0
.TP
.B \-h\fP,\fB \-\-help
Show built\-in help and exit.
.TP
.B \-a\fP,\fB \-\-all
Report every single misspelling [default: \fB\-\-unique\fP].
.TP
.B \-u\fP,\fB \-\-unique
Report each misspelling only once [default].
.TP
.BI \-d \ dict\fR,\fB \ \-\-dictionary\fB= dict
Use this dictionary. \fIdict\fP may be a filename or a dictionary name. Use
multiple times to include multiple dictionaries.
.TP
.B \-\-list\-dicts
List available dictionaries and exit.
.TP
.B \-\-dump\-dict
Build custom dictionary (respecting \fB\-d\fP options).
.TP
.BI \-\-make\-dict\fB= dictfile
Write unknown words to \fIdictfile\fP\&.
.TP
.BI \-i \ string\fR,\fB \ \-\-ignore\fB= regex
Ignore any words matching \fIregex\fP\&.
.TP
.B \-C\fP,\fB \-\-compound
Allow compound words (e.g. \fBgetall\fP) [default].
.TP
.B \-\-no\-compound
Do not allow compound words
.TP
.BI \-W \ N\fR,\fB \ \-\-wordlen\fB= N
Ignore words with <= \fIN\fP characters [default: 3].
.UNINDENT
.SH EXIT STATUS
.INDENT 0.0
.IP \(bu 2
\fB0\fP \- success; no misspellings found.
.IP \(bu 2
\fB1\fP \- at least one misspelling found \fIor\fP there was an error reading
one or more input file (including encoding errors for non\-UTF8 files).
.IP \(bu 2
\fB2\fP \- invalid command line option(s).
.UNINDENT
.SH FILES
.INDENT 0.0
.TP
.B \fB/usr/share/kodespel/\fP
The default dictionaries are stored here.
.UNINDENT
.SH LIMITATIONS
.sp
\fBkodespel\fP has no option to read from standard input. However, on Linux,
you can run \fBkodespel\fP \fB/dev/stdin\fP\&.
.sp
\fBkodespel\fP can only handle \fBUTF\-8\fP encoding (which includes 7\-bit \fBASCII\fP).
It will choke on files that use e.g. \fBISO\-8859\fP encoding.
.sp
\fBkodespel\fP writes its output to \fBstderr\fP, not \fBstdout\fP\&. This makes
it difficult to use it from a script. Try e.g:
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
kodespel <args> 2>&1 | <command>
.ft P
.fi
.UNINDENT
.UNINDENT
.sp
Also, if you get exit status 1, you can\(aqt tell if that\(aqs an actual error
or misspellings were found, without examining the actual output.
.SH COPYRIGHT
.sp
See the file /usr/doc/kodespel\-0.1.1+20220227_e0095c7/LICENSE.txt for license information.
.SH AUTHORS
.sp
kodespel was written by Greg Ward.
.sp
This man page written (mostly copied and adapted from README.md and
the \-\-help output) for the SlackBuilds.org project by B. Watson, and
is licensed under the WTFPL.
.SH SEE ALSO
.sp
The kodespel homepage: \fI\%https://pypi.org/project/kodespel/\fP
.sp
\fBcodespell\fP(1)
.\" Generated by docutils manpage writer.
.

View File

@ -0,0 +1,85 @@
#!/bin/bash
# Slackware build script for kodespel
# Written by B. Watson (urchlay@slackware.uk)
# Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details.
# I'm using a git snapshot rather than the 0.1.1 release because the
# release has 2 fairly major issues:
# - It can't read from standard input even with /dev/stdin as a filename.
# - Its error handling is broken in some cases (e.g. -d with a nonexistent
# dictionary/file) and prints a python stack trace rather than a meaningful
# error message.
cd $(dirname $0) ; CWD=$(pwd)
PRGNAM=kodespel
VERSION=${VERSION:-0.1.1+20220227_e0095c7}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}
PKGTYPE=${PKGTYPE:-tgz}
if [ -z "$ARCH" ]; then
case "$( uname -m )" in
i?86) ARCH=i586 ;;
arm*) ARCH=arm ;;
*) ARCH=$( uname -m ) ;;
esac
fi
if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
exit 0
fi
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}
if [ "$ARCH" = "i586" ]; then
SLKCFLAGS="-O2 -march=i586 -mtune=i686"
LIBDIRSUFFIX=""
elif [ "$ARCH" = "i686" ]; then
SLKCFLAGS="-O2 -march=i686 -mtune=i686"
LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
SLKCFLAGS="-O2 -fPIC"
LIBDIRSUFFIX="64"
else
SLKCFLAGS="-O2"
LIBDIRSUFFIX=""
fi
set -e
rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$VERSION
tar xvf $CWD/$PRGNAM-$VERSION.tar.xz
cd $PRGNAM-$VERSION
chown -R root:root .
find -L . -perm /111 -a \! -perm 755 -a -exec chmod 755 {} \+ -o \
\! -perm /111 -a \! -perm 644 -a -exec chmod 644 {} \+
python3 setup.py install --root=$PKG
# man page by SlackBuild author (adapted from README.md and --help).
mkdir -p $PKG/usr/man/man1
gzip -9c < $CWD/$PRGNAM.1 > $PKG/usr/man/man1/$PRGNAM.1.gz
# bonus dictionary for SlackBuilds (nowhere near complete though).
cat $CWD/sbo.dict > $PKG/usr/share/$PRGNAM/sbo.dict
PKGDOC=$PKG/usr/doc/$PRGNAM-$VERSION
mkdir -p $PKGDOC
cp -a LICENSE* README* $PKGDOC
cat $CWD/$PRGNAM.SlackBuild > $PKGDOC/$PRGNAM.SlackBuild
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE

View File

@ -0,0 +1,10 @@
PRGNAM="kodespel"
VERSION="0.1.1+20220227_e0095c7"
HOMEPAGE="https://pypi.org/project/kodespel/"
DOWNLOAD="https://slackware.uk/~urchlay/src/kodespel-0.1.1+20220227_e0095c7.tar.xz"
MD5SUM="59e11ff81b65da2834cee44567bc80f1"
DOWNLOAD_x86_64=""
MD5SUM_x86_64=""
REQUIRES=""
MAINTAINER="B. Watson"
EMAIL="urchlay@slackware.uk"

View File

@ -0,0 +1,180 @@
.. RST source for kodespel(1) man page. Convert with:
.. rst2man.py kodespel.rst > kodespel.1
.. |version| replace:: 0.1.1+20220227_e0095c7
.. |date| date::
========
kodespel
========
-----------------------------
spell-checker for source code
-----------------------------
:Manual section: 1
:Manual group: SlackBuilds.org
:Date: |date|
:Version: |version|
SYNOPSIS
========
kodespel [**-d** *dictionary*] *file* [*file* ...]
kodespel **--list-dicts**
DESCRIPTION
===========
kodespel is a spellchecker for source code. kodespel's nifty trick
is that it knows how to split common programming identifiers like
'getAllStuff' or 'DoThingsNow' or 'num_objects' or 'HTTPResponse' into
words, feed those to **ispell**\(1), and interpret ispell's output.
Basic usage is to run kodespel on one or more individual files
or directories::
kodespel foo.py main.go README.md
kodespel uses a collection of dictionaries to spellcheck each file.
It always uses the **base** dictionary, which is a set of words
common in source code across languages and platforms. Additionally,
there is a language-specific dictionary for each language kodespel
knows about. Language-specific dictionaries are automatically chosen
for you.
In this example, kodespell will spellcheck each file with:
* **foo.py**: dictionaries **base** and **python**
* **main.go**: dictionaries **base** and **go**
* **README.md**: dictionary **base** only (no language dictionary for Markdown)
If run on a directory, kodespel will recurse into that directory
and spellcheck every file that it recognizes::
kodespel src/
will search for **\*.py**, **\*.c**, **\*.h**, and any other
extension that kodespel has built-in support for.
(Currently: Python, Perl, Go, C, C++, and Java).
Unsupported files are ignored, but if you pass those filenames
explicitly, they will be checked.
Note: the SlackBuilds.org package of **kodespel** includes a
**sbo** dictionary. It will only be used if you enable it
with **-d sbo**.
kodespel ships with several other common dictionaries.
For example, if the program you are spellchecking uses
a lot of Unix system calls, you would add the **unix** dictionary::
kodespel -d unix foo.py main.go README.md
The **-d** option applies to every file being checked.
To see the list of all builtin dictionaries, run::
kodespel --list-dicts
Finally, you can create your own dictionaries,
and use as many of them as you like.
A dictionary is a plain text file with one word per line::
$ cat myproject.dict
nargs
args
You can specify your personal dictionaries with **-d**,
just like kodespel's builtin dictionaries::
kodespel -d unix -d myproject.dict foo.py ...
OPTIONS
=======
-h, --help
Show built-in help and exit.
-a, --all
Report every single misspelling [default: **--unique**].
-u, --unique
Report each misspelling only once [default].
-d dict, --dictionary=dict
Use this dictionary. *dict* may be a filename or a dictionary name. Use
multiple times to include multiple dictionaries.
--list-dicts
List available dictionaries and exit.
--dump-dict
Build custom dictionary (respecting **-d** options).
--make-dict=dictfile
Write unknown words to *dictfile*.
-i string, --ignore=regex
Ignore any words matching *regex*.
-C, --compound
Allow compound words (e.g. **getall**) [default].
--no-compound
Do not allow compound words
-W N, --wordlen=N
Ignore words with <= *N* characters [default: 3].
EXIT STATUS
===========
* **0** - success; no misspellings found.
* **1** - at least one misspelling found *or* there was an error reading
one or more input file (including encoding errors for non-UTF8 files).
* **2** - invalid command line option(s).
FILES
=====
**/usr/share/kodespel/**
The default dictionaries are stored here.
LIMITATIONS
===========
**kodespel** has no option to read from standard input. However, on Linux,
you can run **kodespel** **/dev/stdin**.
**kodespel** can only handle **UTF-8** encoding (which includes 7-bit **ASCII**).
It will choke on files that use e.g. **ISO-8859** encoding.
**kodespel** writes its output to **stderr**, not **stdout**. This makes
it difficult to use it from a script. Try e.g::
kodespel <args> 2>&1 | <command>
Also, if you get exit status 1, you can't tell if that's an actual error
or misspellings were found, without examining the actual output.
COPYRIGHT
=========
See the file /usr/doc/kodespel-|version|/LICENSE.txt for license information.
AUTHORS
=======
kodespel was written by Greg Ward.
This man page written (mostly copied and adapted from README.md and
the --help output) for the SlackBuilds.org project by B. Watson, and
is licensed under the WTFPL.
SEE ALSO
========
The kodespel homepage: https://pypi.org/project/kodespel/
**codespell**\(1)

View File

@ -0,0 +1,19 @@
chmod
chown
dirname
elif
esac
gzip
kodespel
libdirsuffix
makepkg
mtune
perm
pkgdoc
pkgtype
prgnam
sbin
slkcflags
uname
urchlay
wtfpl

View File

@ -0,0 +1,19 @@
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description.
# Line up the first '|' above the ':' following the base package name, and
# the '|' on the right side marks the last column you can put a character in.
# You must make exactly 11 lines for the formatting to be correct. It's also
# customary to leave one space after the ':' except on otherwise blank lines.
|-----handy-ruler------------------------------------------------------|
kodespel: kodespel (spell-checker for source code)
kodespel:
kodespel: kodespel is a spellchecker for source code. kodespel's nifty trick
kodespel: is that it knows how to split common programming identifiers like
kodespel: 'getAllStuff' or 'DoThingsNow' or 'num_objects' or 'HTTPResponse' into
kodespel: words, feed those to ispell, and interpret ispell's output.
kodespel:
kodespel:
kodespel:
kodespel:
kodespel: