Skip to content

Commit

Permalink
feat(shared):Implement GitHub Spellcheck and grammar linting for Pull…
Browse files Browse the repository at this point in the history
… request

This pull request implements the GitHub Spellcheck feature to automatically check the spelling and grammar in commit messages for all Pull Requests (PRs).

Changes Made:
- Added GitHub Spellcheck and grammar linting integration to the repository
- Configured the spellcheck tool to check commit messages in PRs
- Configured the language tool for grammar linting.
- In docs/README.md file corrected the grammar errors.

Fixes: hyperledger-bevel#2327

Signed-off-by: sailajakommineni <[email protected]>
  • Loading branch information
sailajakommineni committed Nov 28, 2023
1 parent 94a63b5 commit 8f11ebe
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 33 deletions.
33 changes: 19 additions & 14 deletions .github/workflows/spellcheck.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ on:
push:
branches:
- "**"
pull_request_target:
branches:
- "**"
pull_request:
paths:
- 'docs/**'
types: [opened, edited, updated]

env:
Expand Down Expand Up @@ -42,32 +42,37 @@ jobs:
- name: Run grammar check
if: ${{ env.GRAMMAR_CHECK_DISABLED == 'false' }}
run: |
cat <<EOF | python -
python - <<EOF
import language_tool_python
# Initialize LanguageTool
tool = language_tool_python.LanguageTool('en-US') # You can specify the language you want to check.
# Specify the directory path
directory_path = 'docs'
# Read the text from your file
# Read the text from your file
file_path = 'docs/README.md' # Update the path accordingly
with open(file_path, 'r', encoding='utf-8') as file:
text = file.read()
# Check for grammar errors
matches = tool.check(text)

# Print grammar errors with line numbers
# Print relevant grammar errors with line numbers
relevant_errors = []
if matches:
for match in matches:
print(f"Grammar error at line {match.offset} - {match.message}")
# Exit with a non-zero code to indicate failure
exit(1)
if match.ruleId == 'MORFOLOGIK_RULE_EN_US':
line_number = text.count('\n', 0, match.offset) + 1
relevant_errors.append((line_number, match.message))
if relevant_errors:
for error in relevant_errors:
line_number, message = error
print(f"Grammar error at line {line_number}: {message}")
exit(1)
else:
# No grammar errors found, print a success message
print("No grammar errors found.")

exit(0)
EOF
35 changes: 16 additions & 19 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,38 @@
# Docs
## About
This directory contains the files required to create open source documentation.
Tools used: [Sphinx](http://www.sphinx-doc.org/)
### Configuration files
* **Index.rst** - This is the main document. Main function of this document is to serve as a welcome page, and to contain the root of the “table of contents tree” (or toctree).This is one of the main things that Sphinx adds to reStructuredText, a way to connect multiple files to a single hierarchy of documents
* **conf.py** - The configuration directory must contain a file named conf.py. This file (containing Python code) is called the “build configuration file” and contains (almost) all configuration needed to customize Sphinx input and output behavior.
* **.md files** - Create all the markdown file which are referenced in the document tree with the appropriate content.
This directory contains the files required to create open-source documentation.
Tools used: [Sphinx] (http://www.sphinx-doc.org/).
## Configuration files
* **index** - This is the main document. This is one of the main things that Sphinx adds to restructured text: a way to connect multiple files to a single hierarchy of documents, including the 'table of contents tree'.
* **conf.py**: The configuration directory must contain a file named conf.py. This file (containing Python code) is called the “build configuration file” and contains (almost) all the configuration needed to customize Sphinx input and output behavior.
* **.md files**: Create all the markdown files that are referenced in the document tree with the appropriate content.

```
./
├── docs
│   ├── source
── index.rst
├── conf.py
├── *.md
| | |── index
  │   ├── conf.py
  │   ├── *.md
│   ├── Makefile
| ├── pip-requirements.txt
|   ├── pip-requirements.txt
│   └── README.md
├── CONTRIBUTING.md
```

### Building the docs
1. Install latest sphinx
1. Install the latest Sphinx.
```
pip install -U Sphinx
```
2. Install the pre-requisites
2. Install the prerequisites.
```
pip install -r pip-requirements.txt
```
3. Build the documents
3. Build the documents.
```
make html
make HTML
or
make.bat html
make.bat HTML
```
4. Access the documents from **build/html/** folder.



4. Access the documents from the **build/html** folder.

0 comments on commit 8f11ebe

Please sign in to comment.