From ee24d81648b6792c7249c5044f6218f59b89e49c Mon Sep 17 00:00:00 2001 From: kasper <33230602+kasper3@users.noreply.github.com> Date: Fri, 30 Mar 2018 12:13:31 -0400 Subject: [PATCH] Add readme for tool and make script generic --- Documentation/manpages/tool/README.md | 28 +++++++++++++ .../manpages/{ => tool}/man-pandoc-filter.py | 0 .../manpages/tool/update-man-pages.sh | 31 ++++++++++++++ Documentation/manpages/update-man-pages.sh | 42 ------------------- 4 files changed, 59 insertions(+), 42 deletions(-) create mode 100644 Documentation/manpages/tool/README.md rename Documentation/manpages/{ => tool}/man-pandoc-filter.py (100%) create mode 100755 Documentation/manpages/tool/update-man-pages.sh delete mode 100755 Documentation/manpages/update-man-pages.sh diff --git a/Documentation/manpages/tool/README.md b/Documentation/manpages/tool/README.md new file mode 100644 index 000000000..3b7b0dd33 --- /dev/null +++ b/Documentation/manpages/tool/README.md @@ -0,0 +1,28 @@ +# Manpage update tool + +Utility to update dotnet-cli documentation from https://github.com/dotnet/docs. + +## Prerequisites + +* Unix OS +* `python` in PATH +* `pandoc` installed +* `pandocfilters` package installed +* `unzip` +* `wget` or `curl` + +## Usage + +```sh +./update-man-pages.sh +``` + +## Ubuntu example (from scratch) + +```sh +sudo apt install -y pandoc python python-pip wget unzip < /dev/null +sudo pip install pandocfilters + +git clone https://github.com/dotnet/cli +./Documentation/manpage/tool/update-man-pages.sh +``` diff --git a/Documentation/manpages/man-pandoc-filter.py b/Documentation/manpages/tool/man-pandoc-filter.py similarity index 100% rename from Documentation/manpages/man-pandoc-filter.py rename to Documentation/manpages/tool/man-pandoc-filter.py diff --git a/Documentation/manpages/tool/update-man-pages.sh b/Documentation/manpages/tool/update-man-pages.sh new file mode 100755 index 000000000..d52051377 --- /dev/null +++ b/Documentation/manpages/tool/update-man-pages.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env sh +# +# Copyright (c) .NET Foundation and contributors. All rights reserved. +# Licensed under the MIT license. See LICENSE file in the project root for full license information. +# + +MANPAGE_TOOL_DIR=$(cd $(dirname $0); pwd) + +cd $MANPAGE_TOOL_DIR/../sdk + +echo "Downloading dotnet/docs master" + +if [ -x "$(command -v curl)" ]; then + curl -sSLO https://github.com/dotnet/docs/archive/master.zip > /dev/null +elif [ -x "$(command -v wget)" ]; then + wget -q https://github.com/dotnet/docs/archive/master.zip > /dev/null +else + echo "Please install curl or wget to proceed" + exit 1 +fi + +unzip -o master.zip > /dev/null +rm master.zip* + +ls docs-master/docs/core/tools/dotnet*.md | while read -r line; + do + echo "Working on $line" + pandoc -s -t man -V section=1 -V header=".NET Core" --column=500 --filter $MANPAGE_TOOL_DIR/man-pandoc-filter.py "$line" -o "$(basename ${line%.md}.1)" +done + +rm -rf docs-master diff --git a/Documentation/manpages/update-man-pages.sh b/Documentation/manpages/update-man-pages.sh deleted file mode 100755 index 25043ee6c..000000000 --- a/Documentation/manpages/update-man-pages.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env sh -# -# Copyright (c) .NET Foundation and contributors. All rights reserved. -# Licensed under the MIT license. See LICENSE file in the project root for full license information. -# - -MANPAGE_TOOL_DIR=$(cd $(dirname $0); pwd) - -cd $MANPAGE_TOOL_DIR/sdk -pandocVersion=2.1.3 -pandocVersionedName=pandoc-$pandocVersion-1-amd64 - -if [ ! -x "$(command -v pandoc)" ]; then - echo "pandoc $pandocVersion not found, installing" - wget -q https://github.com/jgm/pandoc/releases/download/$pandocVersion/$pandocVersionedName.deb > /dev/null - apt install libgmp10 -y - dpkg -i $pandocVersionedName.deb - rm $pandocVersionedName.deb* -fi - -if ! $(python -c "import pandocfilters" &> /dev/null); then - echo "pandocfilters package for python not found, installing v1.4.2" - wget -q https://github.com/jgm/pandocfilters/archive/1.4.2.zip -O pandocfilters-1.4.2.zip > /dev/null - unzip -o pandocfilters-1.4.2.zip > /dev/null - cd pandocfilters-1.4.2 - python setup.py install - cd .. - rm -rf pandocfilters-1.4.2* -fi - -echo "Downloading dotnet/docs master" -wget -q https://github.com/dotnet/docs/archive/master.zip > /dev/null -unzip -o master.zip > /dev/null -rm master.zip* - -ls docs-master/docs/core/tools/dotnet*.md | while read -r line; - do - echo "Working on $line" - pandoc -s -t man -V section=1 -V header=".NET Core" --column=500 --filter $MANPAGE_TOOL_DIR/man-pandoc-filter.py "$line" -o "$(basename ${line%.md}.1)" -done - -rm -rf docs-master