Skip to content

Commit

Permalink
Issue #28: Create docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Nekmo committed Jul 21, 2020
1 parent 533ae75 commit 39e2dae
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 10 deletions.
24 changes: 24 additions & 0 deletions google_keep_tasks/cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import click
from click._compat import iteritems


def choices_prompt(text, choices, default_choice):
Expand All @@ -15,3 +16,26 @@ def choices_prompt(text, choices, default_choice):
if not next(iter(filter(lambda x: x == choice.lower(), map(lambda x: x.lower(), choices_letters))), None):
return default_choice
return choice.lower()


class GkeepHelpFormatter(click.HelpFormatter):
def write(self, string):
"""Remove rst characters."""
return super().write(string.replace('``', ''))


class GkeepContext(click.Context):
def make_formatter(self):
return GkeepHelpFormatter(width=self.terminal_width,
max_width=self.max_content_width)


class GkeepGroup(click.Group):
def make_context(self, info_name, args, parent=None, **extra):
for key, value in iteritems(self.context_settings):
if key not in extra:
extra[key] = value
ctx = GkeepContext(self, info_name=info_name, parent=parent, **extra)
with ctx.scope(cleanup=False):
self.parse_args(ctx, args)
return ctx
10 changes: 5 additions & 5 deletions google_keep_tasks/items.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import click

from google_keep_tasks.cli import GkeepGroup
from google_keep_tasks.exceptions import ItemNotFound
# from google_keep_tasks.management import cli

Expand All @@ -11,12 +12,11 @@ def search_item(items, text):
raise ItemNotFound(text)


@click.group()
@click.group(cls=GkeepGroup)
def items():
"""Notes can have multiple checkbox items. Gkeep can manage
these checkboxes using ``items`` command. This command has subcommands for adding,
editing, deleting or check/uncheck items. To see all subcommands of ``items`` use
``--help``::
"""Use ``items`` command to work with the note checkboxes. This command has
subcommands for adding, editing, deleting or check/uncheck items. To see all
subcommands of ``items`` use ``--help``::
gkeep items --help
Expand Down
5 changes: 3 additions & 2 deletions google_keep_tasks/labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import click
from gkeepapi.exception import LabelException

from google_keep_tasks.cli import GkeepGroup
from google_keep_tasks.utils import pretty_date


Expand All @@ -18,9 +19,9 @@ def format_label_with_timestaps(label):
)


@click.group()
@click.group(cls=GkeepGroup)
def labels():
"""Gkeep can manage Google Keep labels using ``labels`` command.
"""List, create, rename or delete labels using ``labels`` command.
This command has subcommands for adding, searching, editing, or
deleting labels. To see all subcommands of ``labels`` use ``--help``::
Expand Down
3 changes: 2 additions & 1 deletion google_keep_tasks/management.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
import click

from google_keep_tasks.auth import GoogleKeep
from google_keep_tasks.cli import GkeepGroup
from google_keep_tasks.items import items
from google_keep_tasks.labels import labels
from google_keep_tasks.notes import notes


@click.group()
@click.group(cls=GkeepGroup)
@click.option('--debug/--no-debug', default=None)
@click.pass_context
def cli(ctx, debug):
Expand Down
5 changes: 3 additions & 2 deletions google_keep_tasks/notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import gkeepapi
import sys

from google_keep_tasks.cli import GkeepGroup
from google_keep_tasks.exceptions import InvalidColor


Expand Down Expand Up @@ -97,9 +98,9 @@ def get_note_instance(keep, id=None, **kwargs):
return note


@click.group()
@click.group(cls=GkeepGroup)
def notes():
"""Gkeep can manage Google Keep notes using ``notes`` command.
"""Manage Google Keep notes using ``notes`` command.
This command has subcommands for adding, searching, editing, or
deleting notes. To see all subcommands of ``notes`` use ``--help``::
Expand Down

0 comments on commit 39e2dae

Please sign in to comment.