Compare commits

...

1 Commits

Author SHA1 Message Date
Nikita Semenov 575ff876aa feat: general docs api 2023-03-26 21:11:04 +03:00
5 changed files with 102 additions and 5 deletions

View File

@ -392,3 +392,5 @@ placeholder.configure(with: .internetConnection)
} }
``` ```
*/ */
//: #### Others DefaultPlaceholderView

7
docs/api_doc.md Normal file
View File

@ -0,0 +1,7 @@
| Element Type | TI library name | Element Name | Example | Pull Request | Documentation |
| --- | --- | --- | --- | --- | --- |
| Button like elements | TIUIElements | RoundedStatefulButton | https://www.figma.com/file/90eBL1wq2By6z9ZrsBRpoR/iOS.Components?node-id=1-1608 | https://github.com/TouchInstinct/LeadKit/pull/342#issue-1583753852 | Doc is missing |
| Text like elements | TIUIElements | DefaultTitleSubtitleView | https://www.figma.com/file/90eBL1wq2By6z9ZrsBRpoR/iOS.Components?t=6YvNHHIicnvyFsB6-0 | https://github.com/TouchInstinct/LeadKit/pull/342#issue-1583753852 | Doc is missing |
| Others | TIUIElements | SkeletonLayer | https://www.figma.com/file/90eBL1wq2By6z9ZrsBRpoR/iOS.Components?node-id=202-2932&t=hv8FE52pKbXtRZQZ-0 | https://gitlab.ti/touchinstinct/LeadKit/-/merge_requests/1 | https://gitlab.ti/touchinstinct/LeadKit/-/blob/e3ae781f1d944905a6f035287cb354d3002ef2cb/docs/tiuielements/skeletons.md |
| Others | TIUIElements | DefaultPlaceholderView | https://www.figma.com/file/90eBL1wq2By6z9ZrsBRpoR/iOS.Components?node-id=0-1&t=CC3PgNPs7fdUjmBR-0 | | |
| Others | TIUIElements | DefaultPlaceholderView | | | |

View File

@ -407,3 +407,5 @@ placeholder.configure(with: .internetConnection)
} }
} }
``` ```
#### Others DefaultPlaceholderView

View File

@ -0,0 +1,73 @@
import sys
import os
from os.path import isfile, join
from typing import Optional
SRCROOT = os.getenv("SRCROOT")
DOCROOT = SRCROOT + "/docs"
API_PATH = DOCROOT + "/api_doc.md"
# TODO: add url to documentation
def main():
module_name = sys.argv[1]
rows = create_rows(module_name)
if (rows):
append_row(rows)
def create_rows(module_name: str) -> list[str]:
path = DOCROOT + f"/{module_name.lower()}"
files = [path + f"/{f}" for f in os.listdir(path) if isfile(join(path, f))]
info = []
for f in files:
type, name = get_element_info(f)
if type and name:
row = create_row(type, name, module_name)
info.append(row)
return info
def append_row(rows: list[str]):
with open(API_PATH, "a") as f:
for row in rows:
f.write(row)
def get_element_info(file_path: str) -> tuple[Optional[str], Optional[str]]:
line = _get_last_line(file_path)
if not _validate(line):
return None, None
words = line.split()
if len(words) < 3:
print("‼️ Pass arguments like this: `#### ElementType ElementName`!")
return None, None
return words[1], words[2]
def create_row(element_type: str, element_name: str, module_name: str) -> str:
return f"\n| {element_type} | {module_name} | {element_name} | | | |"
def _validate(line: str) -> bool:
return "####" in line
def _get_last_line(path: str) -> str:
with open(path, "r") as f:
return f.readlines()[-1]
if __name__ == "__main__":
main()

View File

@ -7,10 +7,23 @@
# SRCROOT - path to project folder. # SRCROOT - path to project folder.
# #
PLAYGROUNDS="${SRCROOT}/TIFoundationUtils/TIFoundationUtils.app if [ -z ${SRCROOT} ]; then
${SRCROOT}/TIUIElements/TIUIElements.app" echo run \'source setup\ to set SRCROOT environment variable
fi
for playground_path in ${PLAYGROUNDS}; do for module_name in $(cat ${SRCROOT}/project-scripts/ordered_modules_list.txt); do
nef compile --project ${playground_path} APP_FILE=${SRCROOT}/${module_name}/${module_name}.app
nef markdown --project ${playground_path} --output ${SRCROOT}/docs
if [ -d "$APP_FILE" ]; then
nef compile --project $APP_FILE
nef markdown --project $APP_FILE --output ${SRCROOT}/docs
python3 ${SRCROOT}/project-scripts/gen_api_doc.py $module_name
# TODO: Open browser with figma ui documentation
# TODO: Open browser with git remote url
# TODO: Save state to run flow only if there are changes with documentation files
# TODO: Add a flag (like --no-doc) to skip api documentation flow
fi
done done
open ${SRCROOT}/docs/api_doc.md