File tree Expand file tree Collapse file tree 4 files changed +1169
-95
lines changed Expand file tree Collapse file tree 4 files changed +1169
-95
lines changed Original file line number Diff line number Diff line change 1+ name : Compile llms.txt
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ paths :
8+ - ' docs/**/*.mdx'
9+
10+ jobs :
11+ compile :
12+ runs-on : ubuntu-latest
13+ steps :
14+ - uses : actions/checkout@v3
15+ - name : Set up Python
16+ uses : actions/setup-python@v4
17+ with :
18+ python-version : ' 3.x'
19+ - name : Compile llms.txt
20+ run : |
21+ cd docs
22+ python compile_llms.py
23+ - name : Commit and push changes
24+ run : |
25+ git config --local user.email "action@github.com"
26+ git config --local user.name "GitHub Action"
27+ git add docs/llms.txt
28+ git commit -m "Update llms.txt" || exit 0
29+ git push
Original file line number Diff line number Diff line change 1+ import os
2+
3+ def compile_llms_txt ():
4+ # Get the docs directory path (where this script is located)
5+ docs_dir = os .path .dirname (os .path .abspath (__file__ ))
6+ content = ''
7+ # Define names of directories and files to exclude
8+ excluded_names = {'tool' }
9+
10+ # Change to docs directory
11+ os .chdir (docs_dir )
12+
13+ for root , _ , files in os .walk ('.' ):
14+ # Get the last part of the current directory
15+ current_dir = os .path .basename (root )
16+ if current_dir in excluded_names :
17+ continue
18+
19+ for file in files :
20+ if file .endswith ('.mdx' ):
21+ if file in excluded_names :
22+ continue
23+
24+ file_path = os .path .join (root , file )
25+ relative_path = os .path .relpath (file_path , '.' )
26+
27+ with open (file_path , 'r' , encoding = 'utf-8' ) as f :
28+ file_content = f .read ()
29+ content += f"## { relative_path } \n \n { file_content } \n \n "
30+
31+ # Write the complete content, replacing the existing file
32+ output_path = os .path .join (docs_dir , 'llms.txt' )
33+ with open (output_path , 'w' , encoding = 'utf-8' ) as f :
34+ f .write (content )
35+
36+ if __name__ == "__main__" :
37+ compile_llms_txt ()
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments