Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Re-write of directory_writer in Julia #190

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
30 changes: 17 additions & 13 deletions .github/workflows/directory_writer.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Directory writer
on:
schedule:
on: [push]
#schedule:
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
Expand All @@ -10,20 +10,24 @@ on:
# │ │ │ │ │
# │ │ │ │ │
# * * * * *
- cron: '0 0 * * *'
workflow_dispatch:
#- cron: '0 0 * * *'
#workflow_dispatch:
uncomfyhalomacro marked this conversation as resolved.
Show resolved Hide resolved
jobs:
build:
if: github.repository == 'TheAlgorithms/Julia' # We only need this to run in our repository.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get Julia v1.8
uses: julia-actions/setup-julia@v1
with:
fetch-depth: 0
- name: Build directory
uses: TheAlgorithms/scripts/directory_md@main
with:
language: Julia
working-directory: src
filetypes: jl
ignored-directories: docs/,pluto_notebooks/,test/
version: 1.8
uncomfyhalomacro marked this conversation as resolved.
Show resolved Hide resolved
- name: Build DIRECTORY.md
run: julia scripts/directory_writer.jl | tee DIRECTORY.md
- name: Update DIRECTORY.md
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
git add DIRECTORY.md
git commit -am "updating DIRECTORY.md" || true
git push --force origin HEAD:$GITHUB_REF || true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't work as the main branch is protected. We need to create a pull request, and then merge it, just like the previous workflow.

23 changes: 20 additions & 3 deletions DIRECTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* [Affine](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/cipher/affine.jl)
* [Atbash](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/cipher/atbash.jl)
* [Caesar](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/cipher/caesar.jl)
* [Vigenere](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/cipher/vigenere.jl)
* Conversions
* [Conversions](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/conversions/Conversions.jl)
* [Length Conversion](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/conversions/length_conversion.jl)
Expand All @@ -18,14 +19,14 @@
* Data Structures
* [Datastructure](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/data_structures/DataStructure.jl)
* [Binary Heap](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/data_structures/binary_heap.jl)
* [Fenwick Tree](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/data_structures/fenwick_tree.jl)
* [Linked List](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/data_structures/linked_list.jl)
* Binary Tree
* [Basic Binary Search Tree](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/data_structures/binary_tree/basic_binary_search_tree.jl)
* [Basic Binary Tree](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/data_structures/binary_tree/basic_binary_tree.jl)
* [Splay](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/data_structures/binary_tree/splay.jl)
* Disjoint Set
* [Disjoint Set](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/data_structures/disjoint_set/disjoint_set.jl)
* [Fenwick Tree](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/data_structures/fenwick_tree.jl)
* [Linked List](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/data_structures/linked_list.jl)
* Dynamic Programming
* [Dynamicprogramming](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/dynamic_programming/DynamicProgramming.jl)
* [Coin Change](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/dynamic_programming/coin_change.jl)
Expand All @@ -50,13 +51,15 @@
* Math
* [Math](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/math/Math.jl)
* [Abs](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/math/abs.jl)
* [Amicable Numbers](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/math/amicable_numbers.jl)
* [Area](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/math/area.jl)
* [Armstrong Number](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/math/armstrong_number.jl)
* [Average Absolute Deviation](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/math/average_absolute_deviation.jl)
* [Average Mean](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/math/average_mean.jl)
* [Average Median](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/math/average_median.jl)
* [Average Mode](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/math/average_mode.jl)
* [Babylonian Sqrt](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/math/babylonian_sqrt.jl)
* [Binary Length](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/math/binary_length.jl)
* [Catalan Number](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/math/catalan_number.jl)
* [Ceil](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/math/ceil.jl)
* [Collatz Sequence](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/math/collatz_sequence.jl)
Expand All @@ -80,6 +83,7 @@
* [Prime Check](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/math/prime_check.jl)
* [Prime Factors](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/math/prime_factors.jl)
* [Riemann Integration](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/math/riemann_integration.jl)
* [Runge Kutta Integration](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/math/runge_kutta_integration.jl)
* [Sieve Of Eratosthenes](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/math/sieve_of_eratosthenes.jl)
* [Simpsons Integration](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/math/simpsons_integration.jl)
* [Sum Of Arithmetic Series](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/math/sum_of_arithmetic_series.jl)
Expand All @@ -103,6 +107,18 @@
* [Problem 006](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/project_euler/problem_006.jl)
* [Problem 007](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/project_euler/problem_007.jl)
* [Problem 008](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/project_euler/problem_008.jl)
* [Problem 009](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/project_euler/problem_009.jl)
* [Problem 010](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/project_euler/problem_010.jl)
* [Problem 011](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/project_euler/problem_011.jl)
* [Problem 012](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/project_euler/problem_012.jl)
* [Problem 013](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/project_euler/problem_013.jl)
* [Problem 014](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/project_euler/problem_014.jl)
* [Problem 015](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/project_euler/problem_015.jl)
* [Problem 016](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/project_euler/problem_016.jl)
* [Problem 017](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/project_euler/problem_017.jl)
* [Problem 018](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/project_euler/problem_018.jl)
* [Problem 019](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/project_euler/problem_019.jl)
* [Problem 020](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/project_euler/problem_020.jl)
* Project Rosalind
* [Projectrosalind](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/project_rosalind/ProjectRosalind.jl)
* [Count Nucleotide](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/project_rosalind/count_nucleotide.jl)
Expand Down Expand Up @@ -137,12 +153,13 @@
* [Variance](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/statistics/variance.jl)
* Strings
* [Stringalgo](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/strings/StringAlgo.jl)
* [Binary Length](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/strings/binary_length.jl)
* [Detect Anagrams](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/strings/detect_anagrams.jl)
* [Hamming Distance](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/strings/hamming_distance.jl)
* [Is Palindrome](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/strings/is_palindrome.jl)
* [Kmp Substring Search](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/strings/kmp_substring_search.jl)
* [Lcs](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/strings/lcs.jl)
* [Naive Pattern Search](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/strings/naive_pattern_search.jl)
* [Pangram](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/strings/pangram.jl)
* [Rabin Karp](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/strings/rabin_karp.jl)
* [Word Count](https://github.com/TheAlgorithms/Julia/blob/HEAD/src/strings/word_count.jl)

53 changes: 53 additions & 0 deletions scripts/directory_writer.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
URL_BASE = "https://github.com/TheAlgorithms/Julia/blob/HEAD/src"

function get_list_files(path, extension=".jl")
list_files = []
dir_names = String[]
for (root, dirs, files) in walkdir(path)
current_dir = String[]
strip_root = replace(root, "src/" => "")
if strip_root != "src"
push!(dir_names, strip_root)
end
for file in files
if file == "TheAlgorithms.jl"
continue
end
if endswith(file, extension)
push!(current_dir, replace(file, extension => ""))
end
end
if length(current_dir) > 0
push!(list_files, current_dir)
end
end
return list_files, dir_names
end

function title(words)
words = split(replace(lowercase(words), " " => "_"), "_")
titled_words = [uppercasefirst(word) for word in words]
return join(titled_words, " ")
end

function print_directory()
outputs = "\n## TheAlgorithms\n"
files, dirs = get_list_files("src")
for i in eachindex(dirs)
factor = 1
if contains(dirs[i], "/")
dir = split(dirs[i], "/")
factor = length(dir)
dir = dir[end]
else
dir = dirs[i]
end
outputs *= " " ^ factor * "* $(title(dir))\n"
for j in files[i]
outputs *= " " ^ factor * " * [$(title(j))]($URL_BASE/$(dirs[i])/$(replace(j, " " => "%20")).jl)\n"
end
end
println(outputs)
end

print_directory()
uncomfyhalomacro marked this conversation as resolved.
Show resolved Hide resolved