Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 86b3622

Browse files
authored
Merge pull request TheAlgorithms#167 from TheAlgorithms/run-node-UpdateDirectory.js
run: node .github/workflows/UpdateDirectory.js
2 parents 856ec1b + d8a2e7b commit 86b3622

File tree

2 files changed

+5
-54
lines changed

2 files changed

+5
-54
lines changed

‎.github/workflows/update_directory_md.yml‎

Lines changed: 3 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -6,58 +6,9 @@ jobs:
66
runs-on: ubuntu-latest
77
steps:
88
- uses: actions/checkout@master
9-
- uses: actions/setup-python@master
10-
- name: update_directory_md
11-
shell: python
12-
run: |
13-
import os
14-
from typing import Iterator
15-
16-
URL_BASE = "https://github.com/TheAlgorithms/Javascript/blob/master"
17-
g_output = []
18-
19-
20-
def good_filepaths(top_dir: str = ".") -> Iterator[str]:
21-
for dirpath, dirnames, filenames in os.walk(top_dir):
22-
dirnames[:] = [d for d in dirnames if d[0] not in "._"]
23-
for filename in filenames:
24-
if os.path.splitext(filename)[1].lower() == ".js":
25-
yield os.path.join(dirpath, filename).lstrip("./")
26-
27-
28-
def md_prefix(i):
29-
return f"{i * ' '}*" if i else "\n##"
30-
31-
32-
def print_path(old_path: str, new_path: str) -> str:
33-
global g_output
34-
old_parts = old_path.split(os.sep)
35-
for i, new_part in enumerate(new_path.split(os.sep)):
36-
if i + 1 > len(old_parts) or old_parts[i] != new_part:
37-
if new_part:
38-
g_output.append(f"{md_prefix(i)} {new_part.replace('_', ' ')}")
39-
return new_path
40-
41-
42-
def build_directory_md(top_dir: str = ".") -> str:
43-
global g_output
44-
old_path = ""
45-
for filepath in sorted(good_filepaths(), key=str.lower):
46-
filepath, filename = os.path.split(filepath)
47-
if filepath != old_path:
48-
old_path = print_path(old_path, filepath)
49-
indent = (filepath.count(os.sep) + 1) if filepath else 0
50-
url = "/".join((URL_BASE, filepath, filename)).replace(" ", "%20")
51-
filename = os.path.splitext(filename.replace("_", " "))[0]
52-
g_output.append(f"{md_prefix(indent)} [{filename}]({url})")
53-
return "\n".join(g_output)
54-
55-
56-
with open("DIRECTORY.md", "w") as out_file:
57-
out_file.write(build_directory_md(".") + "\n")
58-
59-
- name: Update DIRECTORY.md
60-
run: |
9+
- uses: actions/setup-node@v1
10+
- run: |
11+
node .github/workflows/UpdateDirectory.js
6112
cat DIRECTORY.md
6213
git config --global user.name github-actions
6314
git config --global user.email '${GITHUB_ACTOR}@users.noreply.github.com'

‎DIRECTORY.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
## Linear-Algebra-Javascript
3939
* src
40-
* [la lib](https://github.com/TheAlgorithms/Javascript/blob/master/Linear-Algebra-Javascript/src/la_lib.js)
40+
* [la_lib](https://github.com/TheAlgorithms/Javascript/blob/master/Linear-Algebra-Javascript/src/la_lib.js)
4141
* test
4242
* [test](https://github.com/TheAlgorithms/Javascript/blob/master/Linear-Algebra-Javascript/test/test.js)
4343

@@ -70,8 +70,8 @@
7070
* [CycleSort](https://github.com/TheAlgorithms/Javascript/blob/master/Sorts/CycleSort.js)
7171
* [FlashSort](https://github.com/TheAlgorithms/Javascript/blob/master/Sorts/FlashSort.js)
7272
* [GnomeSort](https://github.com/TheAlgorithms/Javascript/blob/master/Sorts/GnomeSort.js)
73-
* [Heapsort](https://github.com/TheAlgorithms/Javascript/blob/master/Sorts/Heapsort.js)
7473
* [HeapSort](https://github.com/TheAlgorithms/Javascript/blob/master/Sorts/HeapSort.js)
74+
* [Heapsort](https://github.com/TheAlgorithms/Javascript/blob/master/Sorts/Heapsort.js)
7575
* [InsertionSort](https://github.com/TheAlgorithms/Javascript/blob/master/Sorts/InsertionSort.js)
7676
* [MergeSort](https://github.com/TheAlgorithms/Javascript/blob/master/Sorts/MergeSort.js)
7777
* [QuickSort](https://github.com/TheAlgorithms/Javascript/blob/master/Sorts/QuickSort.js)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /