Unverified Commit 473709fc authored by Sylvain Gugger's avatar Sylvain Gugger Committed by GitHub
Browse files

Use doc builder styler (#16412)

* Config update

* Use doc-builder styler

* Cleanup

* Adapt import

* We need it there too!
parent 8049dfa4
...@@ -852,7 +852,7 @@ jobs: ...@@ -852,7 +852,7 @@ jobs:
- run: isort --check-only examples tests src utils - run: isort --check-only examples tests src utils
- run: python utils/custom_init_isort.py --check_only - run: python utils/custom_init_isort.py --check_only
- run: flake8 examples tests src utils - run: flake8 examples tests src utils
- run: python utils/style_doc.py src/transformers docs/source --max_len 119 --check_only - run: doc-builder style src/transformers docs/source --max_len 119 --check_only --path_to_docs docs/source
check_repository_consistency: check_repository_consistency:
working_directory: ~/transformers working_directory: ~/transformers
......
...@@ -48,13 +48,13 @@ quality: ...@@ -48,13 +48,13 @@ quality:
isort --check-only $(check_dirs) isort --check-only $(check_dirs)
python utils/custom_init_isort.py --check_only python utils/custom_init_isort.py --check_only
flake8 $(check_dirs) flake8 $(check_dirs)
python utils/style_doc.py src/transformers docs/source --max_len 119 --check_only doc-builder style src/transformers docs/source --max_len 119 --check_only --path_to_docs docs/source
# Format source code automatically and check is there are any problems left that need manual fixing # Format source code automatically and check is there are any problems left that need manual fixing
extra_style_checks: extra_style_checks:
python utils/custom_init_isort.py python utils/custom_init_isort.py
python utils/style_doc.py src/transformers docs/source --max_len 119 doc-builder style src/transformers docs/source --max_len 119 --path_to_docs docs/source
# this target runs checks on all files and potentially modifies some of them # this target runs checks on all files and potentially modifies some of them
......
...@@ -7,3 +7,8 @@ INSTALL_CONTENT = """ ...@@ -7,3 +7,8 @@ INSTALL_CONTENT = """
""" """
notebook_first_cells = [{"type": "code", "content": INSTALL_CONTENT}] notebook_first_cells = [{"type": "code", "content": INSTALL_CONTENT}]
black_avoid_patterns = {
"{processor_class}": "FakeProcessorClass",
"{model_class}": "FakeModelClass",
"{object_class}": "FakeObjectClass",
}
...@@ -108,6 +108,7 @@ _deps = [ ...@@ -108,6 +108,7 @@ _deps = [
"ftfy", "ftfy",
"fugashi>=1.0", "fugashi>=1.0",
"GitPython<3.1.19", "GitPython<3.1.19",
"hf-doc-builder>=0.2.0",
"huggingface-hub>=0.1.0,<1.0", "huggingface-hub>=0.1.0,<1.0",
"importlib_metadata", "importlib_metadata",
"ipadic>=1.0.0,<2.0", "ipadic>=1.0.0,<2.0",
...@@ -283,12 +284,13 @@ extras["testing"] = ( ...@@ -283,12 +284,13 @@ extras["testing"] = (
"rouge-score", "rouge-score",
"nltk", "nltk",
"GitPython", "GitPython",
"hf-doc-builder",
) )
+ extras["retrieval"] + extras["retrieval"]
+ extras["modelcreation"] + extras["modelcreation"]
) )
extras["quality"] = deps_list("black", "isort", "flake8", "GitPython") extras["quality"] = deps_list("black", "isort", "flake8", "GitPython", "hf-doc-builder")
extras["all"] = ( extras["all"] = (
extras["tf"] extras["tf"]
...@@ -304,7 +306,7 @@ extras["all"] = ( ...@@ -304,7 +306,7 @@ extras["all"] = (
) )
# Might need to add doc-builder and some specific deps in the future # Might need to add doc-builder and some specific deps in the future
extras["docs_specific"] = [] extras["docs_specific"] = ["hf-doc-builder"]
# "docs" needs "all" to resolve all the references # "docs" needs "all" to resolve all the references
extras["docs"] = extras["all"] + extras["docs_specific"] extras["docs"] = extras["all"] + extras["docs_specific"]
......
...@@ -9,8 +9,8 @@ Spec is: github.com/git-lfs/git-lfs/blob/master/docs/custom-transfers.md ...@@ -9,8 +9,8 @@ Spec is: github.com/git-lfs/git-lfs/blob/master/docs/custom-transfers.md
To launch debugger while developing: To launch debugger while developing:
``` [lfs "customtransfer.multipart"] ``` [lfs "customtransfer.multipart"]
path = /path/to/transformers/.env/bin/python args = -m debugpy --listen 5678 --wait-for-client path = /path/to/transformers/.env/bin/python args = -m debugpy --listen 5678 --wait-for-client
/path/to/transformers/src/transformers/commands/transformers_cli.py lfs-multipart-upload ``` """ /path/to/transformers/src/transformers/commands/transformers_cli.py lfs-multipart-upload ```"""
import json import json
import os import os
......
...@@ -18,6 +18,7 @@ deps = { ...@@ -18,6 +18,7 @@ deps = {
"ftfy": "ftfy", "ftfy": "ftfy",
"fugashi": "fugashi>=1.0", "fugashi": "fugashi>=1.0",
"GitPython": "GitPython<3.1.19", "GitPython": "GitPython<3.1.19",
"hf-doc-builder": "hf-doc-builder>=0.2.0",
"huggingface-hub": "huggingface-hub>=0.1.0,<1.0", "huggingface-hub": "huggingface-hub>=0.1.0,<1.0",
"importlib_metadata": "importlib_metadata", "importlib_metadata": "importlib_metadata",
"ipadic": "ipadic>=1.0.0,<2.0", "ipadic": "ipadic>=1.0.0,<2.0",
......
...@@ -19,7 +19,7 @@ import os ...@@ -19,7 +19,7 @@ import os
import re import re
import black import black
from style_doc import style_docstrings_in_code from doc_builder.style_doc import style_docstrings_in_code
# All paths are set with the intent you should run this script from the root of the repo with the command # All paths are set with the intent you should run this script from the root of the repo with the command
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment