Skip to content

Commit

Permalink
upgrade node + docusaurus (#689)
Browse files Browse the repository at this point in the history
* upgrade node

* improve caching for faster build

* upgrade packages

* try to fix mp sidebar error

* fix scroll

* add api to index

* add note about index

* flake8

* use npm ci

Co-authored-by: glicht <[email protected]>
  • Loading branch information
glicht and glicht authored Jun 21, 2021
1 parent ff5b7c5 commit e9ac422
Show file tree
Hide file tree
Showing 9 changed files with 5,882 additions and 9,589 deletions.
17 changes: 14 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@ jobs:

steps:
- checkout
- run:
name: Create Date Weekly File
command: |
date +%Y-%W > date-week.txt
echo "Date week: $(cat date-week.txt)"
- restore_cache:
key: npm-cache-v2-{{ checksum "package-lock.json" }}
- restore_cache:
key: npm-cache-v1-{{ checksum "package-lock.json" }}
key: node-cache-v1-{{ checksum "date-week.txt" }}
- run:
name: Setup Node
command: |
Expand Down Expand Up @@ -58,9 +65,13 @@ jobs:
- store_artifacts:
path: build-site.tar.gz
- save_cache:
key: npm-cache-v1-{{ checksum "package-lock.json" }}
key: npm-cache-v2-{{ checksum "package-lock.json" }}
paths:
- ~/.npm
- save_cache:
key: node-cache-v1-{{ checksum "date-week.txt" }}
paths:
- node_modules
- node_modules/.cache
- persist_to_workspace:
# Must be an absolute path, or relative path from working_directory. This is a directory on the container which is
# taken to be the root directory of the workspace.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
key: ${{ runner.os }}-pip-${{ hashFiles('**/Pipfile.lock') }}
restore-keys: |
${{ runner.os }}-pip-
- run: npm install
- run: npm ci
- uses: actions/setup-python@v1
with:
python-version: '3.9'
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14.15.0
14.17.1
2 changes: 2 additions & 0 deletions content-repo/gen_pydocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ def main():
f'{api_ref_path}/common-server-python',
]
}
# IMPORTANT: if you add additional API items edit the reference index page at gendocs.py
# See: https://github.com/demisto/content-docs/blob/5e58290cad5a70d7217264ad31dafe388dd5f5a9/content-repo/gendocs.py#L682
with open(f'{args.target_dir}/sidebar.json', 'r+') as f:
data = json.load(f)
rn_item_index = next(data.index(item) for item in data if item.get('label') == 'Content Release Notes')
Expand Down
10 changes: 9 additions & 1 deletion content-repo/gendocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def process_release_doc(target_dir: str, release_file: str) -> Optional[DocInfo]
edit_url = f'https://github.com/demisto/content-docs/blob/master/content-repo/extra-docs/releases/{name}.md'
# replace the title to be with one # so it doesn't appear in the TOC
content = re.sub(r'^## Demisto Content Release Notes', '# Demisto Content Release Notes', content)
content = f'---\nid: {name}\ntitle: "{name}"\ncustom_edit_url: {edit_url}\nhide_title: true\n---\n\n' + content
content = f'---\nid: {name}\nsidebar_label: "{name}"\ncustom_edit_url: {edit_url}\n---\n\n' + content
download_msg = "Download"
packs_download = ""
if name > StrictVersion('20.8.0'):
Expand Down Expand Up @@ -678,6 +678,14 @@ def main():
f.write(index_doc_infos(playbooks_doc_infos, PLAYBOOKS_PREFIX))
f.write("\n\n## Scripts\n\n")
f.write(index_doc_infos(script_doc_infos, SCRIPTS_PREFIX))
f.write("\n\n## API Reference\n\n")
api_docs: List[DocInfo] = [
DocInfo('demisto-class', 'Demisto Class',
'The object exposes a series of API methods which are used to retrieve and send data to the Cortex XSOAR Server.', ''),
DocInfo('common-server-python', 'Common Server Python',
'Common functions that will be appended to the code of each integration/script before being executed.', ''),
]
f.write(index_doc_infos(api_docs, 'api'))
f.write("\n\n## Content Release Notes\n\n")
f.write(index_doc_infos(release_doc_infos, RELEASES_PREFIX, headers=('Name', 'Date')))
f.write("\n\nAdditional archived release notes are available"
Expand Down
2 changes: 1 addition & 1 deletion content-repo/gendocs_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def test_process_release_doc(tmp_path, mdx_server):
with open(str(tmp_path / f'{res.id}.md'), 'r') as f:
assert f.readline().startswith('---')
assert f.readline().startswith(f'id: {res.id}')
assert f.readline().startswith(f'title: "{res.id}"')
assert f.readline().startswith(f'sidebar_label: "{res.id}"')
assert f.readline().startswith('custom_edit_url: https://github.com/demisto/content-docs/blob/master/content-repo/extra-docs/releases')


Expand Down
Loading

0 comments on commit e9ac422

Please sign in to comment.