mirror of
https://github.com/TheAlgorithms/PHP.git
synced 2025-07-10 19:46:20 +02:00
Merge pull request #41 from Panquesito7/directory_workflow
Add workflow to add `DIRECTORY.md` with...
This commit is contained in:
58
.github/workflows/directory_workflow.yml
vendored
Normal file
58
.github/workflows/directory_workflow.yml
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
name: directory_md
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
MainSequence:
|
||||
name: DIRECTORY.md
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1 # v2 is broken for git diff
|
||||
- uses: actions/setup-python@v2
|
||||
- name: Setup Git Specs
|
||||
run: |
|
||||
git config --global user.name github-actions
|
||||
git config --global user.email '${GITHUB_ACTOR}@users.noreply.github.com'
|
||||
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
|
||||
- name: Update DIRECTORY.md
|
||||
shell: python
|
||||
run: |
|
||||
import os
|
||||
from typing import Iterator
|
||||
URL_BASE = "https://github.com/TheAlgorithms/PHP/blob/master"
|
||||
g_output = []
|
||||
def good_filepaths(top_dir: str = ".") -> Iterator[str]:
|
||||
fs_exts = tuple(".php".split())
|
||||
for dirpath, dirnames, filenames in os.walk(top_dir):
|
||||
dirnames[:] = [d for d in dirnames if d[0] not in "._"]
|
||||
for filename in filenames:
|
||||
if os.path.splitext(filename)[1].lower() in fs_exts:
|
||||
yield os.path.join(dirpath, filename).lstrip("./")
|
||||
def md_prefix(i):
|
||||
return f"{i * ' '}*" if i else "\n##"
|
||||
def print_path(old_path: str, new_path: str) -> str:
|
||||
global g_output
|
||||
old_parts = old_path.split(os.sep)
|
||||
for i, new_part in enumerate(new_path.split(os.sep)):
|
||||
if i + 1 > len(old_parts) or old_parts[i] != new_part:
|
||||
if new_part:
|
||||
g_output.append(f"{md_prefix(i)} {new_part.replace('_', ' ').title()}")
|
||||
return new_path
|
||||
def build_directory_md(top_dir: str = ".") -> str:
|
||||
global g_output
|
||||
old_path = ""
|
||||
for filepath in sorted(good_filepaths(), key=str.lower):
|
||||
filepath, filename = os.path.split(filepath)
|
||||
if filepath != old_path:
|
||||
old_path = print_path(old_path, filepath)
|
||||
indent = (filepath.count(os.sep) + 1) if filepath else 0
|
||||
url = "/".join((URL_BASE, filepath, filename)).replace(" ", "%20")
|
||||
filename = os.path.splitext(filename.replace("_", " ").title())[0]
|
||||
g_output.append(f"{md_prefix(indent)} [{filename}]({url})")
|
||||
return "# List of all files\n" + "\n".join(g_output)
|
||||
with open("DIRECTORY.md", "w") as out_file:
|
||||
out_file.write(build_directory_md(".") + "\n")
|
||||
- name: Commit DIRECTORY.md
|
||||
run: |
|
||||
git commit -m "updating DIRECTORY.md" DIRECTORY.md || true
|
||||
git diff DIRECTORY.md
|
||||
git push --force origin HEAD:$GITHUB_REF || true
|
77
DIRECTORY.md
77
DIRECTORY.md
@ -1,48 +1,51 @@
|
||||
# Directory
|
||||
# List of all files
|
||||
|
||||
## Ciphers
|
||||
* [Caesarcipher](https://github.com/TheAlgorithms/PHP/blob/master/ciphers/caesarCipher.php)
|
||||
* [Xorcipher](https://github.com/TheAlgorithms/PHP/blob/master/ciphers/XORCipher.php)
|
||||
|
||||
- [Caesar Cipher](https://github.com/TheAlgorithms/PHP/blob/master/ciphers/caesarCipher.php)
|
||||
- [Xor Cipher](https://github.com/TheAlgorithms/PHP/blob/master/ciphers/XORCipher.php)
|
||||
## Conversions
|
||||
* [Binarytodecimal](https://github.com/TheAlgorithms/PHP/blob/master/Conversions/BinaryToDecimal.php)
|
||||
* [Hexadecimaltodecimal](https://github.com/TheAlgorithms/PHP/blob/master/Conversions/HexadecimalToDecimal.php)
|
||||
* [Octaltodecimal](https://github.com/TheAlgorithms/PHP/blob/master/Conversions/OctalToDecimal.php)
|
||||
|
||||
## Maths
|
||||
* [Absolutemax](https://github.com/TheAlgorithms/PHP/blob/master/Maths/AbsoluteMax.php)
|
||||
* [Absolutemin](https://github.com/TheAlgorithms/PHP/blob/master/Maths/AbsoluteMin.php)
|
||||
* [Checkprime](https://github.com/TheAlgorithms/PHP/blob/master/Maths/CheckPrime.php)
|
||||
* [Factorial](https://github.com/TheAlgorithms/PHP/blob/master/Maths/Factorial.php)
|
||||
* [Fastexponentiation](https://github.com/TheAlgorithms/PHP/blob/master/Maths/FastExponentiation.php)
|
||||
* [Fibonacci](https://github.com/TheAlgorithms/PHP/blob/master/Maths/Fibonacci.php)
|
||||
* [Perfectsquare](https://github.com/TheAlgorithms/PHP/blob/master/Maths/PerfectSquare.php)
|
||||
|
||||
- [Absolute Max](https://github.com/TheAlgorithms/PHP/blob/master/Maths/AbsoluteMax.php)
|
||||
- [Absolute Min](https://github.com/TheAlgorithms/PHP/blob/master/Maths/AbsoluteMin.php)
|
||||
- [Check Prime](https://github.com/TheAlgorithms/PHP/blob/master/Maths/CheckPrime.php)
|
||||
- [Factorial](https://github.com/TheAlgorithms/PHP/blob/master/Maths/Factorial.php)
|
||||
- [Perfect Square](https://github.com/TheAlgorithms/PHP/blob/master/Maths/PerfectSquare.php)
|
||||
- [Fast Exponentiation](https://github.com/TheAlgorithms/PHP/blob/master/Maths/FastExponentiation.php)
|
||||
- [Fibonacci Series](https://github.com/TheAlgorithms/PHP/blob/master/Maths/fibonacci.php)
|
||||
|
||||
## Searching
|
||||
|
||||
- [Binary Search](https://github.com/TheAlgorithms/PHP/blob/master/searches/binary_search.php)
|
||||
- [Linear Search](https://github.com/TheAlgorithms/PHP/blob/master/searches/linear_search.php)
|
||||
- [Lower Bound](https://github.com/TheAlgorithms/PHP/blob/master/searches/lower_bound.php)
|
||||
- [Upper Bound](https://github.com/TheAlgorithms/PHP/blob/master/searches/upper_bound.php)
|
||||
## Searches
|
||||
* [Binary Search](https://github.com/TheAlgorithms/PHP/blob/master/searches/binary_search.php)
|
||||
* [Linear Search](https://github.com/TheAlgorithms/PHP/blob/master/searches/linear_search.php)
|
||||
* [Lower Bound](https://github.com/TheAlgorithms/PHP/blob/master/searches/lower_bound.php)
|
||||
* [Upper Bound](https://github.com/TheAlgorithms/PHP/blob/master/searches/upper_bound.php)
|
||||
|
||||
## Sorting
|
||||
|
||||
- [Bubble Sort](https://github.com/TheAlgorithms/PHP/blob/master/sorting/bubbleSort.php)
|
||||
- [Count Sort](https://github.com/TheAlgorithms/PHP/blob/master/sorting/countSort.php)
|
||||
- [Insertion Sort](https://github.com/TheAlgorithms/PHP/blob/master/sorting/insertionSort.php)
|
||||
- [Merge Sort](https://github.com/TheAlgorithms/PHP/blob/master/sorting/mergeSort.php)
|
||||
- [Radix Sort](https://github.com/TheAlgorithms/PHP/blob/master/sorting/radixSort.php)
|
||||
- [Selection Sort](https://github.com/TheAlgorithms/PHP/blob/master/sorting/selectionSort.php)
|
||||
* [Bubblesort](https://github.com/TheAlgorithms/PHP/blob/master/sorting/bubbleSort.php)
|
||||
* [Countsort](https://github.com/TheAlgorithms/PHP/blob/master/sorting/countSort.php)
|
||||
* [Insertionsort](https://github.com/TheAlgorithms/PHP/blob/master/sorting/insertionSort.php)
|
||||
* [Mergesort](https://github.com/TheAlgorithms/PHP/blob/master/sorting/mergeSort.php)
|
||||
* [Radixsort](https://github.com/TheAlgorithms/PHP/blob/master/sorting/radixSort.php)
|
||||
* [Selectionsort](https://github.com/TheAlgorithms/PHP/blob/master/sorting/selectionSort.php)
|
||||
|
||||
## String
|
||||
* [Checkanagram](https://github.com/TheAlgorithms/PHP/blob/master/String/CheckAnagram.php)
|
||||
* [Checkpalindrome](https://github.com/TheAlgorithms/PHP/blob/master/String/CheckPalindrome.php)
|
||||
* [Countvowels](https://github.com/TheAlgorithms/PHP/blob/master/String/CountVowels.php)
|
||||
* [Editdistance](https://github.com/TheAlgorithms/PHP/blob/master/String/EditDistance.php)
|
||||
* [Maxcharacter](https://github.com/TheAlgorithms/PHP/blob/master/String/MaxCharacter.php)
|
||||
* [Reversestring](https://github.com/TheAlgorithms/PHP/blob/master/String/ReverseString.php)
|
||||
* [Reversewords](https://github.com/TheAlgorithms/PHP/blob/master/String/ReverseWords.php)
|
||||
|
||||
- [Check Anagram](https://github.com/TheAlgorithms/PHP/blob/master/String/CheckAnagram.php)
|
||||
- [Check Palindrome](https://github.com/TheAlgorithms/PHP/blob/master/String/CheckPalindrome.php)
|
||||
- [Reverse String](https://github.com/TheAlgorithms/PHP/blob/master/String/ReverseString.php)
|
||||
- [Reverse Words](https://github.com/TheAlgorithms/PHP/blob/master/String/ReverseWords.php)
|
||||
- [Max Characters](https://github.com/TheAlgorithms/PHP/blob/master/String/MaxCharacter.php)
|
||||
- [Count Vowels](https://github.com/TheAlgorithms/PHP/blob/master/String/CountVowels.php)
|
||||
- [Edit Distance](https://github.com/TheAlgorithms/PHP/blob/master/String/EditDistance.php)
|
||||
|
||||
## Number System Conversions
|
||||
|
||||
- [BinaryToDecimal](https://github.com/TheAlgorithms/PHP/blob/master/Conversions/BinaryToDecimal.php)
|
||||
- [OctalToDecimal](https://github.com/TheAlgorithms/PHP/blob/master/Conversions/OctalToDecimal.php)
|
||||
- [HexadecimalToDecimal](https://github.com/TheAlgorithms/PHP/blob/master/Conversions/HexadecimalToDecimal.php)
|
||||
## Tests
|
||||
* [Cipherstest](https://github.com/TheAlgorithms/PHP/blob/master/tests/CiphersTest.php)
|
||||
* [Ciphertest](https://github.com/TheAlgorithms/PHP/blob/master/tests/CipherTest.php)
|
||||
* [Conversionstest](https://github.com/TheAlgorithms/PHP/blob/master/tests/ConversionsTest.php)
|
||||
* [Mathtest](https://github.com/TheAlgorithms/PHP/blob/master/tests/MathTest.php)
|
||||
* Sorting
|
||||
* [Countsorttest](https://github.com/TheAlgorithms/PHP/blob/master/tests/sorting/countSortTest.php)
|
||||
* [Stringtest](https://github.com/TheAlgorithms/PHP/blob/master/tests/StringTest.php)
|
||||
|
Reference in New Issue
Block a user