File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -44,3 +44,16 @@ The comments would be generated by above examples as below:
4444
4545
4646```
47+
48+ ### readme.sh
49+
50+ ` readme.sh ` - it's used to generate the table item in README.md
51+
52+ For example:
53+
54+ ```
55+ $ ./readme.sh ../algorithms/cpp/nextPermutation/nextPermutation.cpp
56+ |31|[Next Permutation](https://oj.leetcode.com/problems/next-permutation/) | [C++](./algorithms/cpp/nextPermutation/nextPermutation.cpp)|Medium|
57+ ```
58+
59+
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+
4+ function usage()
5+ {
6+
7+ echo -e " Usage: ${0} [file]"
8+ echo -e " "
9+ echo -e " Example:"
10+ echo -e " "
11+ echo -e " ${0} ./LargestNumber.cpp"
12+ echo -e " "
13+ }
14+
15+
16+
17+ if [ $# -lt 1 ] || [[ ! -f ${1} ]]; then
18+ usage
19+ exit 255
20+ fi
21+
22+ DIR=` cd $( dirname ${1} ) && pwd -P`
23+ FILE=${DIR} /$( basename ${1} )
24+
25+ URL=` grep Source ${FILE} | awk ' {print $4}' `
26+ title_str=` xidel ${URL} -q -e " css('div.question-title h3')" `
27+ NUM=` echo ${title_str} | awk -F ' .' ' {print $1}' `
28+ TITLE=` echo ${title_str} | awk -F ' .' ' {print $2}' | sed -e ' s/^[[:space:]]*//' `
29+ DIFFCULT=` xidel ${URL} -q -e " css('.question-info')" | grep Difficulty | awk ' {print $2}' `
30+
31+ FILE=` echo ${FILE} | sed " s/.*\/algorithms/\.\/algorithms/" `
32+
33+ echo " |${NUM} |[${TITLE} ](${URL} ) | [C++](${FILE} )|${DIFFCULT} |"
You can’t perform that action at this time.
0 commit comments