Skip to content

Commit

Permalink
include web-sdk and web-client in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
leandrolerena committed Oct 9, 2024
1 parent 8536a75 commit bfd5bed
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@
[submodule "submodules/neops-task-runner-py"]
path = submodules/neops-task-runner-py
url = https://github.com/zebbra/neops-task-runner-py.git
[submodule "submodules/neops-web-sdk"]
path = submodules/neops-web-sdk
url = https://github.com/zebbra/neops-web-sdk.git
[submodule "submodules/neops-web-client"]
path = submodules/neops-web-client
url = https://github.com/zebbra/neops-web-client.git
1 change: 1 addition & 0 deletions docs/make_scripts
1 change: 1 addition & 0 deletions docs/scripts
53 changes: 53 additions & 0 deletions make_scripts/mkdocs-documentation/setup_documentation.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from pathlib import Path

import deepmerge
import yaml
import subprocess
Expand Down Expand Up @@ -90,11 +92,62 @@ def ensure_docs_dir():
shutil.copytree(MKDOCS_DOCS_TEMPLATE, "docs")


def is_ignored_by_git(path):
# Use git check-ignore command to see if the path is ignored
result = subprocess.run(['git', 'check-ignore', path], capture_output=True, text=True)

# If the result's stdout is not empty, the path is ignored
return result.stdout != ''

def create_symlinks():
"""
Create symlinks for all folders in the root of the directory to enable snippets in the documentation
:return:
"""
path = '.'
directories = [d for d in os.listdir(path) if os.path.isdir(os.path.join(path, d))]

config = yaml.load(read_file(MKDOCS_RES), Loader=SafeLoaderIgnoreUnknown)

docs_dir = Path(config.get("docs_dir", "./docs"))

symlinks = [f for f in docs_dir.iterdir() if f.is_symlink()]

for dir in directories:
if is_ignored_by_git(dir):
print(f"-- Skipping {dir} (git-ignored)")
continue
if dir.startswith("."):
print(f"-- Skipping {dir} (hidden directory)")
continue
if dir.startswith("node_modules"):
print(f"-- Skipping {dir} (node_modules)")
continue
if dir.startswith("submodules"):
print(f"-- Skipping {dir} (submodules need to be referenced directly)")
continue
if dir.endswith(docs_dir.name):
print(f"-- Skipping {dir} (docs directory)")
continue
if symlinks not in symlinks:
dest = f"{docs_dir}/{dir}"
print(f"-- Skipping {dir} (already exists)")
if Path(dest).exists():
continue
rel_dir = os.path.relpath(dir, docs_dir)
os.symlink(rel_dir, dest, target_is_directory=True)
print(f"++ Created symlink for {dir}")

print("You can now implement files from all folders in your repo within the docs")




def main():
ensure_mkdocs_custom()
merge_mkdocs_yml()
ensure_docs_dir()
create_symlinks()


if __name__ == '__main__':
Expand Down
2 changes: 2 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ nav:
- Task Runner: '!include ./submodules/neops-task-runner-py/mkdocs_custom.yml'
- Secure Gateway: '!include ./submodules/neops-gql-gtw/mkdocs_custom.yml'
- GraphQL Infrastructure: '!include ./submodules/neops-graphql/mkdocs_custom.yml'
- WebSDK: '!include ./submodules/neops-web-sdk/mkdocs_custom.yml'
- WebClient: '!include ./submodules/neops-web-client/mkdocs_custom.yml'
plugins:
- search
- include_dir_to_nav
Expand Down
2 changes: 2 additions & 0 deletions mkdocs_custom.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ nav:
- Task Runner: '!include ./submodules/neops-task-runner-py/mkdocs_custom.yml'
- Secure Gateway: '!include ./submodules/neops-gql-gtw/mkdocs_custom.yml'
- GraphQL Infrastructure: '!include ./submodules/neops-graphql/mkdocs_custom.yml'
- WebSDK: '!include ./submodules/neops-web-sdk/mkdocs_custom.yml'
- WebClient: '!include ./submodules/neops-web-client/mkdocs_custom.yml'


# --8<-- [start:theme]
Expand Down
1 change: 1 addition & 0 deletions submodules/neops-web-client
Submodule neops-web-client added at d418e7
1 change: 1 addition & 0 deletions submodules/neops-web-sdk
Submodule neops-web-sdk added at 5a8f9f

0 comments on commit bfd5bed

Please sign in to comment.