Skip to content

Commit

Permalink
move assets to the doc project folder
Browse files Browse the repository at this point in the history
  • Loading branch information
maximlt committed Oct 20, 2023
1 parent c4c42d4 commit 35d1154
Showing 1 changed file with 7 additions and 27 deletions.
34 changes: 7 additions & 27 deletions dodo.py
Original file line number Diff line number Diff line change
Expand Up @@ -1891,32 +1891,19 @@ def clean_thumbnails():


def task_doc_move_assets():
"""Copy the projects assets to assets/projname/assets/
This includes:
- the project archive (output of anaconda-project archive)
that is in the ./doc/projname/ folder
- all the files found in the ./projename/assets/ folder, if it exists.
TODO
nbsite corrects the links to the assets in nbsite_fix_links.py
it should not have to do that, instead the assets should be pushed to the
docs folder
"""Copy the projects assets to doc/projname/assets/
"""

def move_assets(root='', name='all'):
if not os.path.exists('assets'):
print('Creating assets/ dir')
os.mkdir('assets')
projects = all_project_names(root) if name == 'all' else [name]
for project in projects:
_move_assets(project)

def _move_assets(name):
# Copy all the files in ./projname/assets to ./assets/projname/assets/
# Copy all the files in ./projname/assets to ./doc/projname/assets/
proj_assets_path = pathlib.Path(name, 'assets')
if proj_assets_path.exists():
dest_assets_path = pathlib.Path('assets', name, 'assets')
dest_assets_path = pathlib.Path('doc', name, 'assets')
if not dest_assets_path.exists():
print(f'Creating dirs {dest_assets_path}')
os.makedirs(dest_assets_path)
Expand All @@ -1934,19 +1921,11 @@ def clean_assets():
assets_dir.rmdir()

def _clean_assets(name):
assets_dir = pathlib.Path('assets')
if not assets_dir.exists():
return
_archives_dir = pathlib.Path('assets', '_archives')
if _archives_dir.exists():
archive_path = _archives_dir / f'{name}.zip'
if archive_path.exists():
print(f'Removing {archive_path}')
archive_path.unlink()
proj_dir = assets_dir / name
doc_dir = pathlib.Path('doc')
proj_dir = doc_dir / name
if not proj_dir.exists():
return
project_assets_dir = assets_dir / name / 'assets'
project_assets_dir = proj_dir / 'assets'
if not project_assets_dir.exists():
return
for asset in project_assets_dir.iterdir():
Expand All @@ -1956,6 +1935,7 @@ def _clean_assets(name):
elif asset.is_dir():
print(f'Removing empty dir {asset}')
shutil.rmtree(asset)
project_assets_dir.rmdir()

return {
'actions': [move_assets],
Expand Down

0 comments on commit 35d1154

Please sign in to comment.