Skip to content

Commit

Permalink
Merge pull request #54 from rohaquinlop/issue-52
Browse files Browse the repository at this point in the history
feat(docs): #52 update documentation
  • Loading branch information
rohaquinlop authored Oct 28, 2024
2 parents 65edd78 + 4c42b4f commit fbe16d9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,8 @@ error, otherwise it will be 0.

## Use the library from python code
The available library commands are:
- `complexipy.main.main`: works the same way as the top-level CLI command `complexipy`
- `complexipy.main.file_complexity`: takes in a file-path and returns the complexity of the file
- `complexipy.main.code_complexity`: takes in a string and (provided the string is a parsable snippet of python code) returns the complexity of the snippet.
- `complexipy.file_complexity`: takes in a file-path and returns the complexity of the file
- `complexipy.code_complexity`: takes in a string and (provided the string is a parsable snippet of python code) returns the complexity of the snippet.

## Example

Expand Down Expand Up @@ -154,15 +153,15 @@ The output of the command

Calling `file_complexity` on a file-path:
```python
>>> from complexipy.main import file_complexity
>>> from complexipy import file_complexity
>>> fc = file_complexity("path/to/file.py")
>>> fc.complexity
1
```

Calling `file_complexity` on a snippet of code:
```python
>>> from complexipy.main import code_complexity
>>> from complexipy import code_complexity
>>> snippet = """for x in range(0, 10):
print(x)
"""
Expand Down
26 changes: 26 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ If the cognitive complexity of a file or a function is greater than the maximum
cognitive cognitive complexity, then the return code will be 1 and exit with
error, otherwise it will be 0.

## Use the library from python code
The available library commands are:
- `complexipy.file_complexity`: takes in a file-path and returns the complexity of the file
- `complexipy.code_complexity`: takes in a string and (provided the string is a parsable snippet of python code) returns the complexity of the snippet.

## Example

### Analyzing a file
Expand Down Expand Up @@ -140,6 +145,27 @@ The cognitive complexity of the file is 1, and the output of the command
────────────────────────── 🎉 Analysis completed! 🎉 ───────────────────────────
```

#### Using the library

Calling `file_complexity` on a file-path:
```python
>>> from complexipy import file_complexity
>>> fc = file_complexity("path/to/file.py")
>>> fc.complexity
1
```

Calling `file_complexity` on a snippet of code:
```python
>>> from complexipy import code_complexity
>>> snippet = """for x in range(0, 10):
print(x)
"""
>>> cc = code_complexity(snippet)
cc.complexity
1
```

#### Explaining the results of the analysis

```python
Expand Down

0 comments on commit fbe16d9

Please sign in to comment.