GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — add readme.sh script to help to generate the content in README.md for… · weimo/leetcode@7f16adf

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • scripts
    • README.md
    • readme.sh
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎scripts/README.md‎

Copy file name to clipboardExpand all lines: scripts/README.md
+13Lines changed: 13 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff 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+
Collapse file

‎scripts/readme.sh‎

Copy file name to clipboard
+33Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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}|"

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.