Skip to content

Commit

Permalink
Merge pull request #68 from calkerns/master
Browse files Browse the repository at this point in the history
Implement Class Docstrings as per Issue #5 #67
  • Loading branch information
Zarad1993 authored Apr 26, 2021
2 parents 7d9329d + ddc35e6 commit 99a6f4a
Show file tree
Hide file tree
Showing 19 changed files with 883 additions and 73 deletions.
2 changes: 2 additions & 0 deletions Contributors.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
* [RCristiano](https://github.com/RCristiano)
* [Hildebrando Pedroni](https://github.com/HildePedroni)
* [Saran Balaji](https://github.com/csaranbalaji)
* [Ashir Gupta](https://github.com/AshirGuptash)
* [Calvin Kerns](https://github.com/calkerns)
44 changes: 40 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,16 @@ To run on a Git Diff patch. Run
$ dyc diff
```


To have Docstrings prepended on a method while development.
Run the following command
```sh
$ dyc diff --watch
```

In order to bypass the text editor pop-up in the confirmation stage. Run
```sh
$ dyc start --skip-confirm
```
## Method Docstring Options

*You can also Setup your own customized Docstring Method Formatting in `dyc.yaml` within `formats` key*
Expand Down Expand Up @@ -93,15 +96,47 @@ $ dyc diff --watch
| `ignore` | Arguments to ignore. | list |
| `prefix` | A prefix like "@param". | str |

<br/>

## Classes Docstring Options

// TODO
*You can also Setup your own customized Docstring Class Formatting in `dyc.yaml` within `formats` key*


*Class*

| Key | Description | Type |
|:-----------------------: |:-----------------------------------------------------------------------------------------------------------------------: |------|
| `keywords` | The necessary keyword to search for in a line that triggers actions (default = ["class"]) | list |
| `enabled` | Determine if formatting is enabled for the extension | bool |
| `indent` | Indentation in a class. Limited options ['tab', '2 spaces', '4 spaces'] | str |
| `indent_content` | Confirm if the content of a docstring has to be indented as well | bool |
| `open` | Starting opener text of a method | str |
| `close` | Close text of a class. This could be the same as opened, but not all languages opening and closing docstrings are same | str |
| `comments` | Comments symbols | str |
| `break_after_open` | Do we add a new line after adding the open strings of a class? | bool |
| `break_after_docstring` | Do we add a new line after adding the docstring? | bool |
| `break_before_close` | Add a new line before closing docstrings on a class | bool |
| `words_per_line` | How many words do we add per docstring? | int |
| `within_scope` | Should the docstring be within the scope of the class or out? Just like JS Method docstrings | bool |


*Parents*

| Key | Description | Type |
|:-----------: |:---------------------------------------------: |:----: |
| `title` | A title for arguments. i.e: "Inheritance" | str |
| `underline` | Underline the title | bool |
| `inline` | Add docstrings all inline or break within. | bool |
| `prefix` | A prefix like "@parent". | str |

<br/>

## Top of file Options

// TODO

### Example
## Example

```sh
$ cd myapp/
Expand Down Expand Up @@ -260,6 +295,8 @@ def hello(name):

## Development

### Setup

Thank you for taking the time to contribute into this project. It is simple but could be really helpful moving forward to all developers.

To get started.
Expand All @@ -273,7 +310,6 @@ To get started.
$ pip install --editable .
```


Before commiting:

Install the pre-commit hooks
Expand Down
5 changes: 3 additions & 2 deletions dyc/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@


class Builder(object):
def __init__(self, filename, config, placeholders=False):
def __init__(self, filename, config, placeholders=False, skip_confirm=False):
self.filename = filename
self.config = config
self.placeholders = placeholders
self.skip_confirm = skip_confirm

details = dict()

Expand All @@ -35,7 +36,7 @@ def initialize(self, change=None):
word.lstrip() for word in line.split(" ") if word.lstrip() in keywords
]
found = len(foundList) > 0 and not is_comment(
line, self.config.get('comments')
line, self.config.get("comments")
)
# Checking an unusual format in method declaration
if foundList:
Expand Down
Loading

0 comments on commit 99a6f4a

Please sign in to comment.