-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add SDK docs #4928
Merged
Merged
Add SDK docs #4928
Changes from 13 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
5172f49
Update readme
zhiltsov-max cb2abd6
Add requirements file for docs
zhiltsov-max bf9e68e
Move sdk developer guide
zhiltsov-max 1b4cc0b
Add sdk and cli integration docs
zhiltsov-max 19c5d83
Add integration docs
zhiltsov-max 7fbe1de
Add rest
zhiltsov-max 22b563f
Add pypi links
zhiltsov-max 4cd549e
Fixes
zhiltsov-max 9fc9262
Update changelog
zhiltsov-max 3b3c9a5
Fix bandit warnings
zhiltsov-max a88927a
Fix linter warnings
zhiltsov-max a4b759f
Fix linter issues
zhiltsov-max a81173b
Add integration components compatibility info
zhiltsov-max d120217
Move doc sections back, rename integration section
zhiltsov-max d1c129f
update changelog
zhiltsov-max 61627cc
Update section name and readme links
zhiltsov-max 4273707
remove rest api page from contributing
zhiltsov-max 56d5434
Remove cli page from manual
zhiltsov-max f3e917e
Remove extra descriptions
zhiltsov-max ff6fa4b
Allow unauthorized access to server api docs
zhiltsov-max a99713d
Add docs for auth methods
zhiltsov-max 17e7ad3
Allow to control SSL verification with env variable in CLI
zhiltsov-max b521f4c
Merge branch 'develop' into zm/update-docs
zhiltsov-max d42834e
Update changelog
zhiltsov-max 7c79c90
Fix host schema detection test after new changes
zhiltsov-max fa39bbc
Update site/content/en/docs/api_sdk/_index.md
zhiltsov-max 3907d1a
Update site/content/en/docs/api_sdk/sdk/developer-guide.md
zhiltsov-max 4249d7c
Update site/content/en/docs/api_sdk/sdk/developer-guide.md
zhiltsov-max 83d7f2e
Fix readme links
zhiltsov-max 2f1f155
Fix links in docs
zhiltsov-max d1ccd8c
Use cli arg for ssl check control
zhiltsov-max 8bdf579
Remove strange parameters
zhiltsov-max File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,87 +1,111 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Copyright (C) 2021-2022 Intel Corporation | ||
# Copyright (C) 2022 CVAT.ai Corporation | ||
# | ||
# SPDX-License-Identifier: MIT | ||
|
||
import os | ||
import shutil | ||
import subprocess | ||
import tarfile | ||
import tempfile | ||
from pathlib import Path | ||
|
||
from packaging import version | ||
import git | ||
import toml | ||
from packaging import version | ||
|
||
# the initial version for the documentation site | ||
MINIMUM_VERSION = version.Version("1.5.0") | ||
|
||
MINIMUM_VERSION='1.5.0' | ||
|
||
def prepare_tags(repo): | ||
tags = {} | ||
for tag in repo.tags: | ||
tag_version = version.parse(tag.name) | ||
if tag_version >= version.Version(MINIMUM_VERSION) and not tag_version.is_prerelease: | ||
if tag_version >= MINIMUM_VERSION and not tag_version.is_prerelease: | ||
release_version = (tag_version.major, tag_version.minor) | ||
if not release_version in tags or tag_version > version.parse(tags[release_version].name): | ||
if release_version not in tags or tag_version > version.parse( | ||
tags[release_version].name | ||
): | ||
tags[release_version] = tag | ||
|
||
return tags.values() | ||
|
||
def generate_versioning_config(filename, versions, url_prefix=''): | ||
|
||
def generate_versioning_config(filename, versions, url_prefix=""): | ||
def write_version_item(file_object, version, url): | ||
file_object.write('[[params.versions]]\n') | ||
file_object.write("[[params.versions]]\n") | ||
file_object.write('version = "{}"\n'.format(version)) | ||
file_object.write('url = "{}"\n\n'.format(url)) | ||
|
||
with open(filename, 'w') as f: | ||
write_version_item(f, 'Latest version', '{}/'.format(url_prefix)) | ||
with open(filename, "w") as f: | ||
write_version_item(f, "Latest version", "{}/".format(url_prefix)) | ||
for v in versions: | ||
write_version_item(f, v, '{}/{}'.format(url_prefix, v)) | ||
write_version_item(f, v, "{}/{}".format(url_prefix, v)) | ||
|
||
|
||
def git_checkout(tagname, repo, temp_dir): | ||
subdirs = ["site/content/en/docs", "site/content/en/images"] | ||
|
||
for subdir in subdirs: | ||
shutil.rmtree(temp_dir / subdir) | ||
|
||
with tempfile.TemporaryFile() as archive: | ||
# `git checkout` doesn't work for this, as it modifies the index. | ||
# `git restore` would work, but it's only available since Git 2.23. | ||
repo.git.archive(tagname, "--", subdir, output_stream=archive) | ||
archive.seek(0) | ||
with tarfile.open(fileobj=archive) as tar: | ||
tar.extractall(temp_dir) | ||
|
||
def git_checkout(tagname, cwd): | ||
docs_dir = os.path.join(cwd, 'site', 'content', 'en', 'docs') | ||
shutil.rmtree(docs_dir) | ||
repo.git.checkout(tagname, '--', 'site/content/en/docs') | ||
images_dir = os.path.join(cwd, 'site', 'content', 'en', 'images') | ||
shutil.rmtree(images_dir) | ||
repo.git.checkout(tagname, '--', 'site/content/en/images') | ||
|
||
def change_version_menu_toml(filename, version): | ||
data = toml.load(filename) | ||
data['params']['version_menu'] = version | ||
data["params"]["version_menu"] = version | ||
|
||
with open(filename,'w') as f: | ||
with open(filename, "w") as f: | ||
toml.dump(data, f) | ||
|
||
|
||
def generate_docs(repo, output_dir, tags): | ||
def run_hugo(content_loc, destination_dir): | ||
subprocess.run([ # nosec | ||
'hugo', | ||
'--destination', | ||
destination_dir, | ||
'--config', | ||
'config.toml,versioning.toml', | ||
], | ||
cwd=content_loc, | ||
) | ||
|
||
cwd = repo.working_tree_dir | ||
content_loc = os.path.join(cwd, 'site') | ||
if not os.path.exists(output_dir): | ||
os.makedirs(output_dir) | ||
|
||
generate_versioning_config(os.path.join(cwd, 'site', 'versioning.toml'), (t.name for t in tags)) | ||
change_version_menu_toml(os.path.join(cwd, 'site', 'versioning.toml'), 'Latest version') | ||
run_hugo(content_loc, output_dir) | ||
|
||
generate_versioning_config(os.path.join(cwd, 'site', 'versioning.toml'), (t.name for t in tags), '/..') | ||
for tag in tags: | ||
git_checkout(tag.name, cwd) | ||
destination_dir = os.path.join(output_dir, tag.name) | ||
change_version_menu_toml(os.path.join(cwd, 'site', 'versioning.toml'), tag.name) | ||
os.makedirs(destination_dir) | ||
run_hugo(content_loc, destination_dir) | ||
repo_root = Path(repo.working_tree_dir) | ||
|
||
with tempfile.TemporaryDirectory() as temp_dir: | ||
content_loc = Path(temp_dir, "site") | ||
shutil.copytree(repo_root / "site", content_loc, symlinks=True) | ||
|
||
def run_hugo(destination_dir): | ||
subprocess.run( # nosec | ||
[ | ||
"hugo", | ||
"--destination", | ||
str(destination_dir), | ||
"--config", | ||
"config.toml,versioning.toml", | ||
], | ||
cwd=content_loc, | ||
check=True, | ||
) | ||
|
||
versioning_toml_path = content_loc / "versioning.toml" | ||
|
||
# Handle the develop version | ||
generate_versioning_config(versioning_toml_path, (t.name for t in tags)) | ||
change_version_menu_toml(versioning_toml_path, "develop") | ||
run_hugo(output_dir) | ||
|
||
generate_versioning_config(versioning_toml_path, (t.name for t in tags), "/..") | ||
for tag in tags: | ||
git_checkout(tag.name, repo, Path(temp_dir)) | ||
change_version_menu_toml(versioning_toml_path, tag.name) | ||
run_hugo(output_dir / tag.name) | ||
|
||
|
||
if __name__ == "__main__": | ||
repo_root = os.getcwd() | ||
repo = git.Repo(repo_root) | ||
output_dir = os.path.join(repo_root, 'public') | ||
repo_root = Path(__file__).resolve().parents[1] | ||
output_dir = repo_root / "public" | ||
|
||
tags = prepare_tags(repo) | ||
generate_docs(repo, output_dir, tags) | ||
with git.Repo(repo_root) as repo: | ||
tags = prepare_tags(repo) | ||
generate_docs(repo, output_dir, tags) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it still a valid link?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that you have added the information below. Should we remove these 3 links?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like to have these links. Maybe, we could provide a TOC section in the beginning? It will simplify navigation for users, because the current page is quite long. Example from Datumaro:
Then, the link will just navigate to the section below.