Skip to content

Commit 86c424b

Browse files
committed
initial commit
1 parent ed8a2eb commit 86c424b

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

.github/actions/make_mdx.sh

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/usr/bin/env bash
2+
3+
# This script downloads the .py and .sh code from the open source repo
4+
# Then it converts the code to markdown files
5+
6+
# Requres two ABSOLUTE paths to the final destination and source directories
7+
# ex: ./make_mdx.sh /Users/potter/dest /Users/potter/src
8+
9+
# make temp directory
10+
WORK_DIR=`mktemp -d`
11+
12+
PY_DEST_REPO="docs/source/ingest/destination_connectors/code/python/"
13+
SH_DEST_REPO="docs/source/ingest/destination_connectors/code/bash/"
14+
DEST_DIR=$1 # first argument to script
15+
PY_SRC_REPO="docs/source/ingest/source_connectors/code/python/"
16+
SH_SRC_REPO="docs/source/ingest/source_connectors/code/bash/"
17+
SRC_DIR=$2 # second argument to script
18+
19+
# Clone the correct directories in the open source repo
20+
cd $WORK_DIR
21+
git init
22+
git remote add -f origin https://github.com/Unstructured-IO/unstructured
23+
git config core.sparseCheckout true
24+
echo "$PY_DEST_REPO" >> .git/info/sparse-checkout
25+
echo "$SH_DEST_REPO" >> .git/info/sparse-checkout
26+
echo "$PY_SRC_REPO" >> .git/info/sparse-checkout
27+
echo "$SH_SRC_REPO" >> .git/info/sparse-checkout
28+
git pull origin main
29+
30+
cp -R $WORK_DIR/$PY_DEST_REPO/. $DEST_DIR/
31+
cp -R $WORK_DIR/$SH_DEST_REPO/. $DEST_DIR/
32+
cp -R $WORK_DIR/$PY_SRC_REPO/. $SRC_DIR/
33+
cp -R $WORK_DIR/$SH_SRC_REPO/. $SRC_DIR/
34+
35+
# Convert the destination_connectors to markdown
36+
cd $DEST_DIR
37+
38+
for f in *.py
39+
do sed -i '1i```python\' $f
40+
sed -i '$ a ```' $f
41+
mv $f $f.mdx
42+
done
43+
44+
for f in *.sh
45+
do sed -i '1i```shell\' $f
46+
sed -i '$ a ```' $f
47+
mv $f $f.mdx
48+
done
49+
50+
# Convert the source_connectors to markdown
51+
cd $SRC_DIR
52+
53+
for f in *.py
54+
do sed -i '1i```python\' $f
55+
sed -i '$ a ```' $f
56+
mv $f $f.mdx
57+
done
58+
59+
for f in *.sh
60+
do sed -i '1i```shell\' $f
61+
sed -i '$ a ```' $f
62+
mv $f $f.mdx
63+
done
64+
65+
rm -rf $WORK_DIR
66+
67+
echo "Markdown files created in $DEST_DIR and $SRC_DIR"

0 commit comments

Comments
 (0)