Skip to content
rho edited this page Oct 22, 2016 · 1 revision

Guideline for Contributing

1 Getting Started

1.1 Prerequisite

See README #manual

1.2 Coding Style

  • our coding style is loosly based on PEP 8
  • 4 spaces for indentation is the must
  • try to fit each line with in 80 columns margin
  • if your indent more than 5 level, something not right

We encourage move beyond the PEP 8 and code more pythonic and human readable form.

1.3 Guidelines for new GNOME developers

Beyond the prerequisite mentioned above, several tools available for assisting the development of GNOME application.

1.3.1 Recommended tools

DevHelp: An API documentation browser for GNOME

Glade: A GUI designer for GTK+ Applications

A good text-editor or IDE (Integrated Development Environment)

2 Inside Repository

There are mainly 3 branches,

Branch Description
master stable working version
dev version for power users
experimental version for hackers/developer

Start with dev branch to begin development, master branch is usually stable branch for common users.

If you want to be upto date with latest development use experimental which might be really 🔥 unstable 🔥.

2.1 Organization

anubad/
├── CONTRIBUTING.org      # this file
├── Makefile.am           # for gnome-style build
├── autogen.sh            # for gnome-style build
├── configure.ac          # for gnome-style build
├── default.ini           # default configuration file
├── demo.pyw              # legacy version of anubad
:
├── assets/               # icons
├── help/                 # help files
├── plugins/              # default plugin folder
│   ├── espeak.py
│   :
│   └── number2word.py
├── ...
:
└── src/                  # source code
    ├── core.py
    ├── main.py
    :
    ├── Makefile          # lists runnable recipies
    └── ui
        ├── home.py       # home ui component
        ├── home.css      # css file for home.py
        :
        └── Makefile      # lists runnable recipies

file naming convention in repository

Pattern Description
plugins/*.{c,py} plugin codes
src/*.{c,py} anubad source codes
src/ui/_*.css css file for Window with same name
src/ui/_*.py widgets componets of Window

2.2 Coding Convention

Every python file should be executed separately

  • Try to include relative functionality in one place
  • Don’t littering your code
  • Include doctest if possible
  • it would be nice to have unit test

2.2.1 naming

  • class names:
    • CamelCase, and capitalize acronyms: HTTPWriter, not HttpWriter.
    • always name a method’s first argument self
    • always name @classmethod first argument cls
    • always use *args and **kwargs for variable argument lists
  • variables
    • normally lower_with_underscores
    • Injected variable name should be in UPPER CASE
    • declarative path variable should start with PATH_ prefix
    • declarative file variable should start with FILE_ prefix
    • precompiled regular expressions re_ prefix
  • function
    • function name should be lower_with_underscores
    • prefix underscore ‘_’ to nested function name
    • no. of underscore ‘_’ represent nested levels
    • encapsulate(nested) function when its trival and tiny
  • modules
    • lower_with_underscores.py. (But, prefer names that don’t need underscores!)

2.3 Comment style

There are various keyword used inside comment, these are what they mean.

Keyword Meaning
FIXME things that could be fixed but i’m lazy
TODO new task or feature/idea not done yet
BUG known annoying bug, which may/may not be fixable
TIP just a friendly NOTE
TESTING thing that are not yet ready
WARN STOP IT, have been then, you don’t want to
NOTE something important, you should know

3 Design

Reference:

  • https://developer.gnome.org/gtk3/stable/chap-css-overview.html
  • https://gist.github.com/ptomato/0fb634ef4098bb89026f

4 Packaging

Running the ./autogen.sh creates the following files:

  • aclocal.m4
  • autom4te.cache
  • config.log
  • config.status
  • configure
  • anubad.desktop
  • install-sh
  • missing
  • Makefile.in
  • Makefile

4.1 Install

Running make install, installs the application in /usr/local/bin and installs the anubad.desktop file in /usr/local/share/applications

You can now run the application by typing “anubad” in the Overview.

4.2 Uninstall

To uninstall, type:

$ make uninstall

4.3 To create a tarball

$ make distcheck

This will create hello-world-1.0.tar.xz

5 Issues

https://guides.github.com/features/issues/

6 Usage

6.1 Searching

searching algorithm and library

6.1.1 threashold levels

level Description
0 exact match, binary search
1 distance map, traverse search
2 similarity search
3 relation search

6.1.2 hashtags

each entries withough

6.1.3 regex support

6.1.3.1 Examples:

“cro*p” → crop, crop up, croup, crock up, crow step

“*chester” → chester, manchester, rochester, winchester and toy manchester

“can????r” → canister and cannular

“andre*[x|y|z]” → andre malraux, andrei tarkovsky, andres, martinez, etc.

“a[c|d|e]{2,}” → acc, accede, ace, add, ade and aec.

6.1.4 plain/raw search

6.2 Suggestions

Suggestions is a feature that gives out possible near matches when a misspelled word is searched for. To have this feature, your system should have libenchant binary (libenchant.so.1) installed and an English dict file for the spell engine to refer (locale doesn’t matter).

7 plugins

by default we have few supporting plugins espeak and number2word.

basic configuration looks like this

[plugin "sajha"]
  name = sajha
  path = /mnt/Core/कामकाज/foss-np/anubad/plugins/
  version = 0.1
  priority = 9
  disable = False
Attributes Description
name
path
version strictly numeric values only
priority lowest number gets high priority i.e 0-9
platforms

User can selects some text in any window, and presses shortcut-combo, without need to copy paste it.

7.1 examples

add examples via plugin/online dictionary/wordnet

7.2 notify

Should the user prefer passive desktop notifications (balloon tips), rather than the application popping up with the definitions, it can be done by enabling Notifications. This is done via the Notify tool button or by right-clicking on anubad’s system tray icon, and tick off the ‘Notifications’ check box in the menu. When notifications are enabled, and the user selects text in a window and presses the hotkey combo, anubad takes the prime definition of that term from

notify library’s binary (libnotify.so.1) should be available on your system. Also the notification-daemon should installed for the notifications to show up.

8 Modes

anubad han mulitlpe mode which are also extended via plugins.

8.1 parential mode

For relatives like Antonyms, Pertainyms, Hypernyms, Hyponyms, Holonyms and Meronyms, where more than one level of relatives may be present, is showed in a tree fashion, in detailed mode. If in simple mode, only one level of relatives are shown even when more levels are present.

E.g. ‘rich’ has ‘poor’ and ‘lean’ alone as antonyms in simple mode. While in detailed mode, ‘poor’ further infers broke, skint, etc. which are shown as children of ‘poor’.

8.2 regex search

Regular expressions can be used to search for a term when you vaguely know it and want to locate it in the thesaurus. anubad’s regular expression pattern closely follows Wildmat syntax by Rich Salz owing to its simplicity.

  • (wildcard) matches any number of (including 0) unknown characters

? (joker) matches one unknown character

[…] (range) matches one unknown character within the range specified

{m, n} (limits) upper & lower limits of the number of characters in a range

[^…] (not in the range) matches one unknown character NOT within the range specified

9 Custom Dictionary

10 User Cache

Look-ups made in anubad are stored as a per-user setting, and can be saved via the popup menu of the search bar or can be cleared too. Other options like showing term familiarity based on polysemy count, display of status icon, etc. can be changed via the Options window.

11 Hacking the code

anubad is divided into small module

12 tkinter-version

Portable, one file python 2 and 3 compatibility without extra dependencies.

This is design was more focused on making the code run with various platforms including

in python tkinter which is no longer in development due font rendering issues, and poor system intergation

/path/to/anubad/demo.pyw

13 plugins

plugin must have the function plugin_main to be plugin.

13.1 plugins

new plugins should be added to.

~/.cache/anubad/plugins/

13.2 meta information about the plugin

variables desc
__authors__ list of authors separated by commas
__support__ support contact for plugins
__version__ numeric version only
__depends__ other dependencies of plugins
__platform__ value to be matched with os.name
__docs__ documentation of the plugins

13.3 Creating the New plugin

14 Tricks

assortment developer friendly interface-engines.

Modes Search prefix
Dump mode ‘d:’
Command Line Access ’$’
Internal Command Mode ‘>’