Name | style50 JSON |
Version |
2.10.4
JSON |
| download |
home_page | https://github.com/cs50/style50 |
Summary | This is style50, with which code can be checked against the CS50 style guide |
upload_time | 2024-08-03 04:16:43 |
maintainer | None |
docs_url | None |
author | CS50 |
requires_python | None |
license | GPLv3 |
keywords |
style
style50
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# style50
This is style50, a tool with which code can be checked against the CS50 style guide.
## Installation
```bash
pip install style50
```
In order to style check C, C++, or Java code, a recent version (`>=14.0.0`) of `clang-format` must be installed. `clang-format` may be downloaded [here](https://clang.llvm.org/docs/ClangFormat.html).
### Windows
Along with most of CS50's command line tools, `style50` supports being run on Windows but only via the [Linux Subsystem in Windows 10](https://msdn.microsoft.com/en-us/commandline/wsl/install_guide). After launching it, `style50` can be installed using the `pip` command above.
## Usage
```
usage: style50 [-h] [-o MODE] [-v] [-V] [-E] [-i PATTERN] file [file ...]
positional arguments:
file file or directory to lint
optional arguments:
-h, --help show this help message and exit
-o MODE, --output MODE
output mode, which can be character (default), split,
unified, score, or json
-v, --verbose print full tracebacks of errors
-V, --version show program's version number and exit
-E, --extensions print supported file extensions (as JSON list) and
exit
-i PATTERN, --ignore PATTERN
paths/patterns to be ignored
```
`character`, `split`, and `unified` modes output character-based, side-by-side, and unified (respectively) diffs between the inputted file and the correctly styled version. `score` outputs the raw percentage of correct (unchanged) lines, while `json` outputs a json object containing information pertinent to the CS50 IDE plugin (coming soon).
## Language Support
`style50` currently supports the following languages:
- C++
- C
- Python
- Javascript
- Java
### Adding a new language
Adding a new language is very simple. Language checks are encoded as classes which inherit from the `StyleCheck` base class (see `style50/languages.py` for more real-world examples). The following is a template for style checks which allows style50 to check the imaginary FooBar language for style.
```python
import re
from style50 import StyleCheck, Style50
class FooBar(StyleCheck):
# REQUIRED: this property informs style50 what file extensions this
# check should be run on (in this case, all .fb and .foobar files)
extensions = ["fb", "foobar"]
# REQUIRED: should return a correctly styled version of `code`
def style(self, code):
# All FooBar code is perfectly styled
return code
# OPTIONAL: should return the number of comments in `code`.
# If this function is not defined, `style50` will not warn the student about
# too few comments
def count_comments(self, code):
# A real-world, check would need to worry about not counting '#' in string-literals
return len(re.findall(r"#.*", code))
```
All classes which inherit from `StyleCheck` are automatically registered with `style50`'s `Style50` class, making style50 easily extensible. Adding the following to the above code creates a script which checks the code that `style50` already does as well as FooBar programs.
```python
# Style check the current directory, printing a unified diff
Style50("unified").run(["."])
```
Raw data
{
"_id": null,
"home_page": "https://github.com/cs50/style50",
"name": "style50",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "style, style50",
"author": "CS50",
"author_email": "sysadmins@cs50.harvard.edu",
"download_url": "https://files.pythonhosted.org/packages/08/c8/2742b1b02d815c39070a0f12344b286792be15238ae15eb322c67d8a499c/style50-2.10.4.tar.gz",
"platform": null,
"description": "# style50\n\nThis is style50, a tool with which code can be checked against the CS50 style guide.\n\n## Installation\n\n```bash\npip install style50\n```\n\nIn order to style check C, C++, or Java code, a recent version (`>=14.0.0`) of `clang-format` must be installed. `clang-format` may be downloaded [here](https://clang.llvm.org/docs/ClangFormat.html).\n\n### Windows\n\nAlong with most of CS50's command line tools, `style50` supports being run on Windows but only via the [Linux Subsystem in Windows 10](https://msdn.microsoft.com/en-us/commandline/wsl/install_guide). After launching it, `style50` can be installed using the `pip` command above.\n\n## Usage\n\n```\nusage: style50 [-h] [-o MODE] [-v] [-V] [-E] [-i PATTERN] file [file ...]\n\npositional arguments:\nfile file or directory to lint\n\noptional arguments:\n-h, --help show this help message and exit\n-o MODE, --output MODE\n output mode, which can be character (default), split,\n unified, score, or json\n-v, --verbose print full tracebacks of errors\n-V, --version show program's version number and exit\n-E, --extensions print supported file extensions (as JSON list) and\n exit\n-i PATTERN, --ignore PATTERN\n paths/patterns to be ignored\n```\n\n`character`, `split`, and `unified` modes output character-based, side-by-side, and unified (respectively) diffs between the inputted file and the correctly styled version. `score` outputs the raw percentage of correct (unchanged) lines, while `json` outputs a json object containing information pertinent to the CS50 IDE plugin (coming soon).\n\n## Language Support\n\n`style50` currently supports the following languages:\n\n- C++\n- C\n- Python\n- Javascript\n- Java\n\n### Adding a new language\n\nAdding a new language is very simple. Language checks are encoded as classes which inherit from the `StyleCheck` base class (see `style50/languages.py` for more real-world examples). The following is a template for style checks which allows style50 to check the imaginary FooBar language for style.\n\n```python\nimport re\n\nfrom style50 import StyleCheck, Style50\n\n\nclass FooBar(StyleCheck):\n\n # REQUIRED: this property informs style50 what file extensions this\n # check should be run on (in this case, all .fb and .foobar files)\n extensions = [\"fb\", \"foobar\"]\n\n # REQUIRED: should return a correctly styled version of `code`\n def style(self, code):\n # All FooBar code is perfectly styled\n return code\n\n # OPTIONAL: should return the number of comments in `code`.\n # If this function is not defined, `style50` will not warn the student about\n # too few comments\n def count_comments(self, code):\n # A real-world, check would need to worry about not counting '#' in string-literals\n return len(re.findall(r\"#.*\", code))\n```\n\nAll classes which inherit from `StyleCheck` are automatically registered with `style50`'s `Style50` class, making style50 easily extensible. Adding the following to the above code creates a script which checks the code that `style50` already does as well as FooBar programs.\n\n```python\n # Style check the current directory, printing a unified diff\n Style50(\"unified\").run([\".\"])\n```\n",
"bugtrack_url": null,
"license": "GPLv3",
"summary": "This is style50, with which code can be checked against the CS50 style guide",
"version": "2.10.4",
"project_urls": {
"Homepage": "https://github.com/cs50/style50"
},
"split_keywords": [
"style",
" style50"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "bd860c28daca8cc6d4ab3fa3aab87998c8a0c599078fd2849bb1dea35f052007",
"md5": "7f98d4c29c35babe4e6f9c45847a4282",
"sha256": "a5dd0cd89f1084ac8ebcc1c13efda21b0c19a877000d9bdf5551df59d2aae48c"
},
"downloads": -1,
"filename": "style50-2.10.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7f98d4c29c35babe4e6f9c45847a4282",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 25423,
"upload_time": "2024-08-03T04:16:42",
"upload_time_iso_8601": "2024-08-03T04:16:42.006101Z",
"url": "https://files.pythonhosted.org/packages/bd/86/0c28daca8cc6d4ab3fa3aab87998c8a0c599078fd2849bb1dea35f052007/style50-2.10.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "08c82742b1b02d815c39070a0f12344b286792be15238ae15eb322c67d8a499c",
"md5": "9b11c4c293b5cf251e34e65f6ea9b800",
"sha256": "13dedcb9e1652c53c4eea68d35df680127abfbc14f98a7dd081b2c7fc39a45d3"
},
"downloads": -1,
"filename": "style50-2.10.4.tar.gz",
"has_sig": false,
"md5_digest": "9b11c4c293b5cf251e34e65f6ea9b800",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 25004,
"upload_time": "2024-08-03T04:16:43",
"upload_time_iso_8601": "2024-08-03T04:16:43.660524Z",
"url": "https://files.pythonhosted.org/packages/08/c8/2742b1b02d815c39070a0f12344b286792be15238ae15eb322c67d8a499c/style50-2.10.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-03 04:16:43",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "cs50",
"github_project": "style50",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "style50"
}