Skip to content

Commit 8a0176b

Browse files
committed
Added Travis CI build configuration and scripts for generating documentation and pdf file. README updated to include links to documentation, dependencies, dependent libraries and mystery files as well the self-link. Added TravisCI badge to README.
1 parent 1af4a2e commit 8a0176b

File tree

8 files changed

+219
-3
lines changed

8 files changed

+219
-3
lines changed

.travis.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
language: csharp
2+
sudo: required
3+
dist: xenial
4+
mono: latest
5+
dotnet: 2.2
6+
before_install:
7+
- sudo apt-get install -y texlive texlive-lang-cyrillic texlive-latex-extra python-pygments ghostscript
8+
- export TRAVIS_REPO_NAME=$(echo "${TRAVIS_REPO_SLUG#*/}" | sed 's/.*/\u&/')
9+
script:
10+
- dotnet build -c Release
11+
after_success:
12+
- bash ./generate-pdf.sh
13+
- bash ./publish-docs.sh

README.md

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,32 @@
1+
[![Build Status](https://travis-ci.com/linksplatform/Converters.svg?branch=master)](https://travis-ci.com/linksplatform/Converters)
12
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/d9ed13ebe0884892a325f787aca376f3)](https://app.codacy.com/app/drakonard/Converters?utm_source=github.com&utm_medium=referral&utm_content=linksplatform/Converters&utm_campaign=Badge_Grade_Dashboard)
23
[![CodeFactor](https://www.codefactor.io/repository/github/linksplatform/converters/badge)](https://www.codefactor.io/repository/github/linksplatform/converters)
34

4-
# Converters
5+
# [Converters](https://github.com/linksplatform/Converters)
56

67
LinksPlatform's Platform.Converters Class Library.
78

8-
Namespace: Platform.Converters
9+
Namespace: [Platform.Converters](https://linksplatform.github.io/Converters/api/Platform.Converters.html)
910

1011
Forked from: [Konard/LinksPlatform/Platform/Platform.Helpers](https://github.com/Konard/LinksPlatform/tree/1a9a968bea64460cfbf0f075b0336bc2179e295c/Platform/Platform.Helpers)
1112

12-
NuGet package: [Platform.Converters](https://www.nuget.org/packages/Platform.Converters)
13+
NuGet package: [Platform.Converters](https://www.nuget.org/packages/Platform.Converters)
14+
15+
## [Documentation](https://linksplatform.github.io/Converters)
16+
[PDF file](https://linksplatform.github.io/Converters/Platform.Converters.pdf) with code for e-readers.
17+
18+
## Depend on
19+
* [Platform.Reflection](https://github.com/linksplatform/Reflection)
20+
* [Platform.Reflection.Sigil](https://github.com/linksplatform/Reflection.Sigil)
21+
22+
## Dependent libraries
23+
* [Platform.Numbers](https://github.com/linksplatform/Numbers)
24+
25+
## Mystery files
26+
* [.travis.yml](https://github.com/linksplatform/Converters/blob/master/.travis.yml) - Travis CI build configuration.
27+
* [docfx.json](https://github.com/linksplatform/Converters/blob/master/docfx.json) and [toc.yml](https://github.com/linksplatform/Converters/blob/master/toc.yml) - DocFX build configuration.
28+
* [format-document.sh](https://github.com/linksplatform/Converters/blob/master/format-document.sh) - script for formating `tex` file for generating PDF from it.
29+
* [format-csharp-files.py](https://github.com/linksplatform/Converters/blob/master/format-csharp-files.py) - script for formating single `.cs` file as a part of `tex` file.
30+
* [generate-pdf.sh](https://github.com/linksplatform/Converters/blob/master/generate-pdf.sh) - script that generates PDF with code for e-readers.
31+
* [publish-docs.sh](https://github.com/linksplatform/Converters/blob/master/publish-docs.sh) - script that publishes generated documentation and PDF with code for e-readers to `gh-pages` branch.
32+
* [push-nuget.bat](https://github.com/linksplatform/Converters/blob/master/push-nuget.bat) - Windows script for publishing current version of NuGet package.

docfx.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"metadata": [
3+
{
4+
"src": [
5+
{
6+
"files": [ "**/*.sln" ],
7+
"exclude": [ "**/bin/**", "**/obj/**" ],
8+
"src": ""
9+
}
10+
],
11+
"dest": "obj/api"
12+
}
13+
],
14+
"build": {
15+
"content": [
16+
{
17+
"files": [ "**/*.yml" ],
18+
"src": "obj/api",
19+
"dest": "api"
20+
},
21+
{
22+
"files": [ "*.md", "toc.yml" ]
23+
}
24+
],
25+
"globalMetadata": {
26+
"_appTitle": "LinksPlatform's Platform.$TRAVIS_REPO_NAME Library",
27+
"_enableSearch": true,
28+
"_gitContribute": {
29+
"branch": "master"
30+
},
31+
"_gitUrlPattern": "github"
32+
},
33+
"markdownEngineName": "markdig",
34+
"dest": "_site",
35+
"xrefService": [ "https://xref.docs.microsoft.com/query?uid={uid}" ]
36+
}
37+
}

format-csharp-files.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/python
2+
# -*- coding: utf-8 -*-
3+
import sys
4+
reload(sys)
5+
sys.setdefaultencoding('utf-8')
6+
for line in sys.stdin.readlines():
7+
line = line.strip()
8+
print "\\index{%s}" % (line.replace('_','\\_'))
9+
print "\\begin{section}{%s}" % (line.replace('_','\\_'))
10+
#print "\\inputminted[tabsize=2,breaklines,linenos=true]{csharp}{%s}" % (line)
11+
print "\\begin{minted}[tabsize=2,breaklines,breakanywhere,linenos=true,xleftmargin=7mm,framesep=4mm]{csharp}"
12+
f = open(line,"rt")
13+
c = "\n".join([x.strip("\n") for x in f.readlines()])
14+
f.close()
15+
c = c.replace(u'\ufeff','')
16+
print c
17+
print "\\end{minted}"
18+
print "\\end{section}"
19+
print

format-document.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
set -e # Exit with nonzero exit code if anything fails
3+
4+
# Download fvextra package
5+
wget https://raw.githubusercontent.com/gpoore/fvextra/cc1c0c5f7b92023cfec67084e2a87bdac520414c/fvextra/fvextra.sty
6+
7+
echo """
8+
\\documentclass[11pt,a4paper,fleqn]{report}
9+
\\usepackage[left=5mm,top=5mm,right=5mm,bottom=5mm]{geometry}
10+
\\textwidth=200mm
11+
\\usepackage[utf8]{inputenc}
12+
\\usepackage[T1]{fontenc}
13+
\\usepackage[T2A]{fontenc}
14+
\\usepackage{fvextra}
15+
\\usepackage{minted}
16+
\\usemintedstyle{vs}
17+
\\usepackage{makeidx}
18+
\\usepackage[columns=1]{idxlayout}
19+
\\makeindex
20+
\\renewcommand{\\thesection}{\\arabic{chapter}.\\arabic{section}}
21+
\\setcounter{chapter}{1}
22+
\\setcounter{section}{0}
23+
\\usepackage[tiny]{titlesec}
24+
\\titlespacing\\chapter{0mm}{0mm}{0mm}
25+
\\titlespacing\\section{0mm}{0mm}{0mm}
26+
\\DeclareUnicodeCharacter{221E}{\\ensuremath{\\infty}}
27+
\\DeclareUnicodeCharacter{FFFD}{\\ensuremath{ }}
28+
\\usepackage{fancyhdr}
29+
\\pagestyle{fancy}
30+
\\fancyhf{}
31+
\\fancyfoot[C]{\\thepage}
32+
\\renewcommand{\\headrulewidth}{0mm}
33+
\\renewcommand{\\footrulewidth}{0mm}
34+
\\renewcommand{\\baselinestretch}{0.7}
35+
\\begin{document}
36+
\\sf
37+
\\noindent{\\Large LinksPlatform's Platform.${TRAVIS_REPO_NAME} Class Library}
38+
"""
39+
40+
# Remove auto-generated code files
41+
find ./obj -type f -iname "*.cs" -delete
42+
43+
# CSharp files
44+
#find * -type f -iname '*.cs' -exec sh -c 'enconv "{}"' \;
45+
find . -type f -iname '*.cs' | sort -b | python format-csharp-files.py
46+
47+
echo """
48+
\\printindex
49+
\\end{document}
50+
"""

generate-pdf.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
set -e # Exit with nonzero exit code if anything fails
3+
4+
# Generate tex file
5+
bash format-document.sh > document.tex
6+
7+
# Generate pdf
8+
latex -shell-escape document.tex
9+
makeindex document
10+
latex -shell-escape document.tex
11+
dvipdf document.dvi document.pdf
12+
dvips document.dvi
13+
14+
# Copy pdf to publish location (with be used in the next script)
15+
mkdir _site
16+
cp document.pdf _site/Platform.${TRAVIS_REPO_NAME}.pdf

publish-docs.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/bash
2+
set -e # Exit with nonzero exit code if anything fails
3+
4+
# Settings
5+
SOURCE_BRANCH="master"
6+
TARGET_BRANCH="gh-pages"
7+
SHA=$(git rev-parse --verify HEAD)
8+
COMMIT_USER_NAME="linksplatform-docs"
9+
COMMIT_USER_EMAIL="konard@yandex.ru"
10+
REPOSITORY="github.com/linksplatform/${TRAVIS_REPO_NAME}"
11+
12+
# Pull requests and commits to other branches shouldn't try to deploy, just build to verify
13+
if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_BRANCH" != "$SOURCE_BRANCH" ]; then
14+
echo "Skipping deploy."
15+
exit 0
16+
fi
17+
18+
# Insert repository name into DocFX's configuration files
19+
sed -i "s/\$TRAVIS_REPO_NAME/${TRAVIS_REPO_NAME}/g" toc.yml
20+
sed -i "s/\$TRAVIS_REPO_NAME/${TRAVIS_REPO_NAME}/g" docfx.json
21+
22+
# DocFX installation
23+
nuget install docfx.console
24+
mono $(ls | grep "docfx.console.")/tools/docfx.exe docfx.json
25+
26+
# Clone the existing gh-pages for this repo into out/
27+
# Create a new empty branch if gh-pages doesn't exist yet (should only happen on first deply)
28+
git clone https://$REPOSITORY out
29+
cd out
30+
git checkout $TARGET_BRANCH || git checkout --orphan $TARGET_BRANCH
31+
cd ..
32+
33+
# Clean out existing contents
34+
rm -rf out/**/* || exit 0
35+
36+
# Copy genereted docs site
37+
cp -r _site/* out
38+
39+
cd out
40+
41+
# Do not use index.md
42+
cp README.html index.html
43+
44+
# Now let's go have some fun with the cloned repo
45+
git config user.name "$COMMIT_USER_NAME"
46+
git config user.email "$COMMIT_USER_EMAIL"
47+
git remote rm origin
48+
git remote add origin https://$COMMIT_USER_NAME:$TOKEN@$REPOSITORY.git
49+
50+
# Commit the "changes", i.e. the new version.
51+
# The delta will show diffs between new and old versions.
52+
git add --all
53+
git commit -m "Deploy to GitHub Pages: ${SHA}"
54+
55+
# Now that we're all set up, we can push.
56+
git push https://$COMMIT_USER_NAME:$TOKEN@$REPOSITORY.git $TARGET_BRANCH

toc.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- name: Home
2+
href: README.md
3+
- name: API Documentation
4+
href: obj/api/
5+
homepage: api/Platform.$TRAVIS_REPO_NAME.html

0 commit comments

Comments
 (0)