Skip to content

Commit c5367ba

Browse files
committed
fix nsgportal, change nav_order, allow update specific plugin
1 parent 69dbd49 commit c5367ba

File tree

3 files changed

+35
-31
lines changed

3 files changed

+35
-31
lines changed

code/plugins/reformat_plugin.py

+13-6
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def append_to_file(filepath, filename, parent, output_file):
3737
with open(output_file, 'w') as out:
3838
out.write(text)
3939

40-
def reformat_plugin_dir(plugin_input_dir, plugin_name, plugin_type='wiki'):
40+
def reformat_plugin_dir(plugin_input_dir, plugin_name, order, plugin_type='wiki'):
4141
# plugins_output_dir = '/Users/dtyoung/Documents/EEGLAB/sccn.github.io/plugins'
4242
plugin_output_dir = os.path.join('/Users/dtyoung/Documents/EEGLAB/sccn.github.io/plugins', plugin_name)
4343
if not os.path.exists(plugin_output_dir):
@@ -58,8 +58,11 @@ def reformat_plugin_dir(plugin_input_dir, plugin_name, plugin_type='wiki'):
5858
parent: Plugins
5959
categories: plugins
6060
has_children: true
61+
nav_order: {order}
6162
---
62-
'''.format(plugin_name=plugin_name)
63+
To view the plugin source code, please visit the plugin's [GitHub repository](https://github.com/sccn/{plugin_name}).
64+
65+
'''.format(plugin_name=plugin_name, order=order)
6366
text = append_text + text
6467
with open(index_file, 'w') as out:
6568
out.write(text)
@@ -77,21 +80,25 @@ def reformat_plugin_dir(plugin_input_dir, plugin_name, plugin_type='wiki'):
7780
title: {plugin_name}
7881
long_title: {plugin_name}
7982
parent: Plugins
83+
nav_order: {order}
8084
---
81-
'''.format(plugin_name=plugin_name)
85+
To view the plugin source code, please visit the plugin's [GitHub repository](https://github.com/sccn/{plugin_name}).
86+
87+
'''.format(plugin_name=plugin_name, order=order)
8288
text = append_text + text
8389
with open(index_file, 'w') as out:
8490
out.write(text)
8591

8692
# main
8793
def main():
88-
if len(sys.argv) != 4:
89-
print('Usage: python test.py <plugin_dir_path> <plugin_name> <plugin_type>')
94+
if len(sys.argv) != 5:
95+
print('Usage: python test.py <plugin_dir_path> <plugin_name> <plugin_type> <nav_order>')
9096
sys.exit(1)
9197
dirpath = sys.argv[1]
9298
plugin_name = sys.argv[2]
9399
plugin_type = sys.argv[3]
94-
reformat_plugin_dir(dirpath, plugin_name, plugin_type)
100+
order = sys.argv[4]
101+
reformat_plugin_dir(dirpath, plugin_name, order, plugin_type)
95102

96103
if __name__ == "__main__":
97104
main()

code/plugins/update_plugins.py

+22-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import os
22
import subprocess
3+
import sys
34

45
def run_command(command):
56
result = subprocess.run(command, shell=True, capture_output=False, text=True)
67
if result.returncode != 0:
78
print(f"Command failed: {command}\nError: {result.stderr}")
89
return result
910

10-
def update_repo(repo, script, plugin_type='readme'):
11+
def update_repo(repo, order, plugin_type='readme'):
1112
print(f"Updating {repo}...")
1213
current_dir = os.getcwd()
1314
repo_path = os.path.join(current_dir, 'github', repo)
@@ -22,16 +23,28 @@ def update_repo(repo, script, plugin_type='readme'):
2223
run_command(f'git clone https://github.com/sccn/{repo}.git {repo_path}')
2324

2425
os.chdir(current_dir)
25-
run_command(f'python {script} {repo_path} {repo} {plugin_type}')
26+
script = 'reformat_plugin.py'
27+
command = f'python {script} {repo_path} {repo} {plugin_type} {order}'
28+
run_command(command)
2629

2730
if __name__ == "__main__":
2831
# if 'github' not in current directory, create it
2932
if not os.path.exists('github'):
3033
os.makedirs('github')
31-
32-
# wiki_plugins = ['SIFT', 'get_chanlocs', 'NFT', 'PACT', 'nsgportal', 'clean_rawdata']
33-
# for plugin in wiki_plugins:
34-
# update_repo(plugin, "reformat_plugin.py", 'wiki')
35-
readme_plugins = ['ARfitStudio'] #, 'roiconnect', 'EEG-BIDS', 'trimOutlier', 'groupSIFT', 'nwbio', 'ICLabel', 'dipfit', 'eegstats', 'PowPowCAT', 'PACTools', 'zapline-plus', 'amica', 'fMRIb', 'relica', 'std_dipoleDensity', 'imat', 'viewprops', 'cleanline','NIMA', 'firfilt']
36-
for plugin in readme_plugins:
37-
update_repo(plugin, "reformat_plugin.py", "readme")
34+
if len(sys.argv) == 0:
35+
order = 1
36+
wiki_plugins = ['SIFT', 'get_chanlocs', 'NFT', 'PACT', 'nsgportal', 'clean_rawdata']
37+
for plugin in wiki_plugins:
38+
update_repo(plugin, order, 'wiki')
39+
order += 1
40+
readme_plugins = ['ARfitStudio', 'roiconnect', 'EEG-BIDS', 'trimOutlier', 'groupSIFT', 'nwbio', 'ICLabel', 'dipfit', 'eegstats', 'PowPowCAT', 'PACTools', 'zapline-plus', 'amica', 'fMRIb', 'relica', 'std_dipoleDensity', 'imat', 'viewprops', 'cleanline','NIMA', 'firfilt']
41+
for plugin in readme_plugins:
42+
update_repo(plugin, order, "readme")
43+
order += 1
44+
elif len(sys.argv) == 3:
45+
plugin_name = sys.argv[1]
46+
plugin_type = sys.argv[2]
47+
update_repo(plugin_name, 1, plugin_type)
48+
else:
49+
print('Usage: python update_plugins.py <plugin_name> <plugin_type>')
50+
sys.exit(1)

code/plugins/update_plugins.sh

-16
This file was deleted.

0 commit comments

Comments
 (0)