2020-09-13 12:35:11 +02:00
|
|
|
Contribution Guidelines
|
|
|
|
=======================
|
2019-10-16 09:41:43 +02:00
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
Filing an Issue
|
|
|
|
---------------
|
2019-10-16 09:41:43 +02:00
|
|
|
|
|
|
|
* Ensure the bug was not already reported by searching GitHub Issues.
|
|
|
|
* If you're unable to find an open issue addressing the problem,
|
|
|
|
open a new one. Be sure to include a title and clear description,
|
|
|
|
as much relevant information as possible, such as Awesome errors,
|
|
|
|
and a config sample or an executable test case
|
|
|
|
(using Vicious as a stand-alone library)
|
|
|
|
demonstrating the expected behavior that is not occurring.
|
|
|
|
|
|
|
|
Please re-read your issue once again to avoid a couple of common mistakes
|
|
|
|
(you can and should use this as a checklist):
|
|
|
|
|
|
|
|
* Is the description of the issue itself sufficient?
|
|
|
|
Make sure that it's obvious
|
2020-09-13 12:35:11 +02:00
|
|
|
|
|
|
|
* What the problem is
|
|
|
|
* How it could be fixed
|
|
|
|
* How your proposed solution would look like
|
|
|
|
|
2019-10-16 09:41:43 +02:00
|
|
|
* Have you provide the versions of Vicious and related software?
|
|
|
|
We would like to how you installed Vicious, which OS you're using,
|
|
|
|
the version of the software or what kind of hardware you are trying
|
|
|
|
to get information from.
|
|
|
|
* Is the issue already documented?
|
|
|
|
* Does the issue involve one problem, and one problem only?
|
|
|
|
Some people seem to think there is a limit of issues they can or should open.
|
|
|
|
There is no limit of issues they can or should open.
|
|
|
|
While it may seem appealing to be able to dump all your issues
|
|
|
|
into one ticket, that means that someone who solves one of your issues
|
|
|
|
cannot mark the issue as closed.
|
|
|
|
* Is anyone going to need the feature? Only post features that you
|
|
|
|
(or an incapacitated friend you can personally talk to) require.
|
|
|
|
Do not post features because they seem like a good idea.
|
|
|
|
If they're really useful, they'll be requested by someone who requires them.
|
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
Requesting for Merging a Patch
|
|
|
|
------------------------------
|
2019-10-16 09:41:43 +02:00
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
#. `Fork this repository`_
|
|
|
|
#. Check out the source code with::
|
2019-10-16 09:41:43 +02:00
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
git clone https://github.com/YOUR_GITHUB_USERNAME/vicious.git
|
|
|
|
cd vicious
|
2019-10-16 09:41:43 +02:00
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
#. Start working on your patch. If you want to add a new widget type,
|
|
|
|
see the ``templates`` directory for a more detailed guide.
|
|
|
|
#. Have a look at ``helpers.lua`` and ``spawn.lua``
|
|
|
|
for possible helper functions.
|
|
|
|
#. Make sure your code follows the coding conventions below and check the code
|
|
|
|
with ``luacheck``. This *should fail* at first, but you can continually
|
|
|
|
re-run it until you're done::
|
2019-10-16 09:41:43 +02:00
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
luacheck --config tools/luacheckrc .
|
2019-10-16 09:41:43 +02:00
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
#. Make sure your code works under all Lua versions claimed supported
|
2019-10-16 09:41:43 +02:00
|
|
|
by Vicious, namely 5.1, 5.2 and 5.3.
|
2020-09-13 12:35:11 +02:00
|
|
|
#. Update the copyright notices of the files you modified. Vicious is
|
2019-10-16 09:41:43 +02:00
|
|
|
collectively licensed under GPLv2+, and to protect the freedom of the users,
|
|
|
|
copyright holders need to be properly documented.
|
2020-09-13 12:35:11 +02:00
|
|
|
#. Try to note your changes under ``CHANGELOG.rst``. If you find it is
|
2019-10-16 09:41:43 +02:00
|
|
|
difficult to phrase the changes, you can leave it for us.
|
2020-09-13 12:35:11 +02:00
|
|
|
#. Add_ the changes, commit_ them and push_ the result, like this::
|
2019-10-16 09:41:43 +02:00
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
git add widgets/bar_baz.lua README.md
|
|
|
|
git commit -m '[bar_baz] Add widget type'
|
|
|
|
git add helpers.lua CHANGELOG.rst
|
|
|
|
git commit -m '[helpers] Fix foo'
|
|
|
|
git push
|
2019-10-16 09:41:43 +02:00
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
#. Finally, `create a pull request`_. We'll then review and merge it.
|
2019-10-16 09:41:43 +02:00
|
|
|
|
|
|
|
In any case, thank you very much for your contributions!
|
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
Coding Conventions
|
|
|
|
------------------
|
2019-10-16 09:41:43 +02:00
|
|
|
|
|
|
|
This section introduces a guideline for writing idiomatic, robust
|
|
|
|
and future-proof widget type code.
|
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
Whitespace in Expressions and Statements
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2019-10-16 09:41:43 +02:00
|
|
|
|
|
|
|
Avoid extraneous whitespace in the following situations:
|
|
|
|
|
|
|
|
* Immediately inside parentheses or brackets. Braces, however, are exceptions
|
|
|
|
to this rule:
|
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
.. code-block:: lua
|
|
|
|
|
|
|
|
foo(bar[1], { baz = 2 }) -- yes
|
|
|
|
foo( bar[ 1 ], {baz = 2} ) -- no
|
2019-10-16 09:41:43 +02:00
|
|
|
|
|
|
|
* Immediately before a comma, semicolon, or colon.
|
|
|
|
* Immediately before the open parenthesis, braces, quote, etc.
|
2019-10-20 08:58:32 +02:00
|
|
|
that starts the argument list of a function call; or the open bracket
|
2019-10-16 09:41:43 +02:00
|
|
|
that starts an indexing. In other words, prefer these:
|
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
.. code-block:: lua
|
|
|
|
|
|
|
|
foo(bar, baz)
|
|
|
|
foo{ bar, baz }
|
|
|
|
foo"bar"
|
|
|
|
foo[[bar]]
|
|
|
|
foo[bar]
|
2019-10-16 09:41:43 +02:00
|
|
|
|
|
|
|
* Trailing at the end of line or (newline) at the end of file.
|
|
|
|
|
|
|
|
Always surround these binary operators with a single space on either side:
|
2020-09-13 12:35:11 +02:00
|
|
|
assignment (``=``), comparisons, Booleans (``and``, ``or``, ``not``).
|
2019-10-16 09:41:43 +02:00
|
|
|
If operators with different priorities are used, consider adding whitespace
|
|
|
|
around the operators with the lowest priorities. Use your own judgment;
|
|
|
|
however, never use more than one space, and always have
|
|
|
|
the same amount of whitespace on both sides of a binary operator.
|
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
Indentation
|
|
|
|
^^^^^^^^^^^
|
2019-10-16 09:41:43 +02:00
|
|
|
|
|
|
|
Use 4 *spaces* per indentation level.
|
|
|
|
|
|
|
|
Continuation lines should align wrapped elements either vertically
|
|
|
|
inside parentheses, brackets and braces, or using a hanging indent
|
|
|
|
(the opening parenthesis of a parenthesized statement is the last
|
|
|
|
non-whitespace character of the line, with subsequent lines being indented
|
|
|
|
until the closing parenthesis), e.g.
|
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
.. code-block:: lua
|
|
|
|
|
|
|
|
-- Vertically aligned
|
|
|
|
long_function_call{ foo, bar,
|
|
|
|
baz }
|
2019-10-16 09:41:43 +02:00
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
-- Hanging indentation
|
|
|
|
long_function_call(
|
|
|
|
foo, bar
|
|
|
|
baz)
|
2019-10-16 09:41:43 +02:00
|
|
|
|
2019-10-20 08:58:32 +02:00
|
|
|
The closing brace or bracket on multi-line constructs may either line up under
|
2019-10-16 09:41:43 +02:00
|
|
|
the first character of the line that starts the construct, as in:
|
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
.. code-block:: lua
|
|
|
|
|
|
|
|
long_function_call{
|
|
|
|
foo = 1, bar = 2,
|
|
|
|
baz = 3,
|
|
|
|
}
|
2019-10-16 09:41:43 +02:00
|
|
|
|
|
|
|
In this case, and this case only, the trailing comma is acceptable
|
|
|
|
to avoid diff noises when more values are added,
|
|
|
|
but since Vicious often deal with system APIs which rarely ever change,
|
|
|
|
it's occasionally helpful to do so.
|
|
|
|
|
|
|
|
Trailing right parentheses, however, are not allowed.
|
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
Maximum Line Length
|
|
|
|
^^^^^^^^^^^^^^^^^^^
|
2019-10-16 09:41:43 +02:00
|
|
|
|
2019-10-20 08:58:32 +02:00
|
|
|
If possible, try to limit all *code* lines to a maximum
|
|
|
|
of 80 characters. In case you find some lines in your patch would be
|
|
|
|
more readable exceeding this limit, feel free to discuss with us.
|
|
|
|
Comments and long strings need not to follow this restriction however.
|
2019-10-16 09:41:43 +02:00
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
As one might have noticed, the syntactic sugars ``f{<fields>}``
|
|
|
|
(for ``f({<fields>})``) and ``f'<string>'``
|
|
|
|
(or ``f"<string>"``/``f[[<string>]]``, for ``f('<string>')``)
|
|
|
|
are especially preferred to squeeze the line length to this limit.
|
2019-10-16 09:41:43 +02:00
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
Blank Lines
|
|
|
|
^^^^^^^^^^^
|
2019-10-16 09:41:43 +02:00
|
|
|
|
|
|
|
Surround function definitions with a single blank line. Extra blank lines
|
|
|
|
may be used (sparingly) to separate groups of related functions.
|
|
|
|
Blank lines may be omitted between a bunch of related one-liners
|
|
|
|
(e.g. a set of dummy implementations).
|
|
|
|
Use blank lines in functions, sparingly, to indicate logical sections.
|
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
Requiring Libraries
|
|
|
|
^^^^^^^^^^^^^^^^^^^
|
2019-10-16 09:41:43 +02:00
|
|
|
|
|
|
|
All standard libraries should be localized before used
|
|
|
|
for the matter of performance.
|
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
``require``'s should always be put at the top of the source file,
|
2019-10-16 09:41:43 +02:00
|
|
|
just after the copyright header, and before module globals and constants,
|
|
|
|
and grouped in the following order:
|
|
|
|
|
|
|
|
1. Standard libraries
|
|
|
|
2. Related third-party libraries
|
|
|
|
3. Local libraries
|
|
|
|
|
|
|
|
For example,
|
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
.. code-block:: lua
|
2019-10-16 09:41:43 +02:00
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
local type = type
|
|
|
|
local table = { concat = table.concat, insert = table.insert }
|
2019-10-16 09:41:43 +02:00
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
local awful = require("awful")
|
2019-10-16 09:41:43 +02:00
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
local helpers = require("vicious.helpers")
|
|
|
|
|
|
|
|
String Quotes
|
|
|
|
^^^^^^^^^^^^^
|
2019-10-16 09:41:43 +02:00
|
|
|
|
|
|
|
In Lua, single-quoted strings and double-quoted strings are the same,
|
|
|
|
so the choice is totally up to you, but please be consistent within a module.
|
|
|
|
When a string contains single or double quote characters, however,
|
|
|
|
use the other one to avoid backslashes in the string. It improves readability:
|
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
.. code-block:: lua
|
|
|
|
|
|
|
|
'"key": "value"' -- good
|
|
|
|
"\"key\": \"value\"" -- no good
|
2019-10-16 09:41:43 +02:00
|
|
|
|
|
|
|
It is preferable to add a newline immediately after the opening long bracket:
|
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
.. code-block:: lua
|
|
|
|
|
|
|
|
foo = [[
|
|
|
|
this is a really,
|
|
|
|
really,
|
|
|
|
really long text]]
|
2019-10-16 09:41:43 +02:00
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
Naming Conventions
|
|
|
|
^^^^^^^^^^^^^^^^^^
|
2019-10-16 09:41:43 +02:00
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
Avoid using the characters ``l`` (lowercase letter el),
|
|
|
|
``O`` (uppercase letter oh), or ``I`` (uppercase letter eye)
|
|
|
|
as single character variable names. In some fonts, these characters
|
|
|
|
are indistinguishable from the 1's and 0's.
|
2019-10-16 09:41:43 +02:00
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
Constants
|
|
|
|
"""""""""
|
2019-10-16 09:41:43 +02:00
|
|
|
|
|
|
|
Constants are usually defined on a module level
|
|
|
|
and written in all capital letters with underscores separating words.
|
2020-09-13 12:35:11 +02:00
|
|
|
Examples include ``MAX_OVERFLOW`` and ``TOTAL``.
|
2019-10-16 09:41:43 +02:00
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
Function and Variable Names
|
|
|
|
"""""""""""""""""""""""""""
|
2019-10-16 09:41:43 +02:00
|
|
|
|
|
|
|
Function names should be lowercase, with words separated by underscores
|
|
|
|
as necessary to improve readability.
|
|
|
|
|
|
|
|
Variable names follow the same convention as function names.
|
|
|
|
|
|
|
|
When you find it difficult to give descriptive names,
|
|
|
|
use the functions and variable anonymously.
|
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
Performance Tips
|
|
|
|
^^^^^^^^^^^^^^^^
|
2019-10-16 09:41:43 +02:00
|
|
|
|
|
|
|
Vicious is meant to be run as part of the Awesome window manager,
|
|
|
|
thus any little overhead may defect the responsiveness of the UI.
|
|
|
|
While Lua is famous for its performance, there are a few things
|
|
|
|
one can do to make use of all of its power.
|
|
|
|
|
|
|
|
**Never** use global variables. This includes the standard libraries,
|
|
|
|
which, again, must be localized before use. Remember, every widget type
|
|
|
|
is to be called repeatedly every few seconds.
|
|
|
|
|
|
|
|
Use closures when possible:
|
|
|
|
|
|
|
|
* Define constants on the module level.
|
|
|
|
* Avoid re-fetching the values that are not not meant to change.
|
|
|
|
|
|
|
|
However, declare a variable only when you need it, to avoid declaring it
|
|
|
|
without an initial value (and therefore you seldom forget to initialize it).
|
|
|
|
Moreover, you shorten the scope of the variable, which increases readability.
|
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
Copyright Header
|
|
|
|
^^^^^^^^^^^^^^^^
|
2019-10-16 09:41:43 +02:00
|
|
|
|
|
|
|
Vicious is released under the GNU GNU General Public License
|
|
|
|
version 2 or later and each contributor holds the copyright
|
|
|
|
on their contributions. To make this collective control effective,
|
|
|
|
each source file must include a notice of the following format
|
|
|
|
denoting the name of all authors
|
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
.. code-block:: lua
|
|
|
|
|
|
|
|
-- <one line to give the program's name and a brief idea of what it does.>
|
|
|
|
-- Copyright (C) <year> <name of author> <<email that can be use for contact>>
|
|
|
|
--
|
|
|
|
-- This file is part of Vicious.
|
|
|
|
--
|
|
|
|
-- Vicious is free software: you can redistribute it and/or modify
|
|
|
|
-- it under the terms of the GNU General Public License as
|
|
|
|
-- published by the Free Software Foundation, either version 2 of the
|
|
|
|
-- License, or (at your option) any later version.
|
|
|
|
--
|
|
|
|
-- Vicious is distributed in the hope that it will be useful,
|
|
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
-- GNU General Public License for more details.
|
|
|
|
--
|
|
|
|
-- You should have received a copy of the GNU General Public License
|
|
|
|
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
Comments
|
|
|
|
^^^^^^^^
|
2019-10-16 09:41:43 +02:00
|
|
|
|
|
|
|
Comments that contradict the code are worse than no comments.
|
|
|
|
Always make a priority of keeping the comments up-to-date when the code changes!
|
|
|
|
|
|
|
|
You should use two spaces after a sentence-ending period
|
|
|
|
in multi-sentence comments, except after the final sentence.
|
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
Block Comments
|
|
|
|
""""""""""""""
|
2019-10-16 09:41:43 +02:00
|
|
|
|
|
|
|
Block comments generally apply to some (or all) code that follows them,
|
|
|
|
and are indented to the same level as that code. Each line of a block comment
|
2020-09-13 12:35:11 +02:00
|
|
|
starts with ``--`` and a single space, unless text inside the comment
|
|
|
|
is indented, or it is to comment out code.
|
2019-10-16 09:41:43 +02:00
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
Paragraphs inside a block comment are separated by a line containing
|
|
|
|
``--`` only. The best example is the copyright notice in the section above.
|
2019-10-16 09:41:43 +02:00
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
The ``--[[...]]`` style may only be used for commenting out source code.
|
2019-10-16 09:41:43 +02:00
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
Inline Comments
|
|
|
|
"""""""""""""""
|
2019-10-16 09:41:43 +02:00
|
|
|
|
|
|
|
An inline comment is a comment on the same line as a statement.
|
|
|
|
Inline comments should be separated by at least two spaces from the statement.
|
2020-09-13 12:35:11 +02:00
|
|
|
They should start with ``--`` and one single space.
|
2019-10-16 09:41:43 +02:00
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
Influences
|
|
|
|
----------
|
2019-10-16 09:41:43 +02:00
|
|
|
|
2020-09-13 12:35:11 +02:00
|
|
|
These contributing guideline are heavily influenced by that of ``youtube-dl``,
|
2019-10-16 09:41:43 +02:00
|
|
|
PEP 8, Programming in Lua and the performance tips in Lua Programming Gems.
|
2020-09-13 12:35:11 +02:00
|
|
|
|
|
|
|
.. _Fork this repository: https://github.com/vicious-widgets/vicious/fork
|
|
|
|
.. _Add: https://git-scm.com/docs/git-add
|
|
|
|
.. _commit: https://git-scm.com/docs/git-commit
|
|
|
|
.. _push: https://git-scm.com/docs/git-push
|
|
|
|
.. _create a pull request:
|
|
|
|
https://help.github.com/articles/creating-a-pull-request
|