Skip to content

Commit

Permalink
Added Travis CI build configuration and scripts for generating docume…
Browse files Browse the repository at this point in the history
…ntation 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.
  • Loading branch information
Konard committed Aug 23, 2019
1 parent 246b783 commit ee135db
Show file tree
Hide file tree
Showing 10 changed files with 240 additions and 9 deletions.
15 changes: 15 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
language: csharp
sudo: required
dist: xenial
mono: latest
dotnet: 2.2
before_install:
- sudo apt-get install -y texlive texlive-lang-cyrillic texlive-latex-extra python-pygments ghostscript
- export TRAVIS_REPO_NAME=$(echo "${TRAVIS_REPO_SLUG#*/}" | sed 's/.*/\u&/')
- export SOURCE_BRANCH="master"
script:
- dotnet build -c Release
- dotnet test -c Release
after_success:
- bash ./generate-pdf.sh
- bash ./publish-docs.sh
9 changes: 8 additions & 1 deletion Platform.Communication.sln
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,18 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{83D7A9BC-9B53-476B-AEF2-D29BB81FB95C}"
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
.travis.yml = .travis.yml
docfx.json = docfx.json
format-csharp-files.py = format-csharp-files.py
format-document.sh = format-document.sh
generate-pdf.sh = generate-pdf.sh
publish-docs.sh = publish-docs.sh
push-nuget.bat = push-nuget.bat
README.md = README.md
toc.yml = toc.yml
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Platform.Communication.Tests", "Platform.Communication.Tests\Platform.Communication.Tests.csproj", "{9E717AE9-2881-4249-8451-CDA262E4E6EF}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Platform.Communication.Tests", "Platform.Communication.Tests\Platform.Communication.Tests.csproj", "{9E717AE9-2881-4249-8451-CDA262E4E6EF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
26 changes: 23 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@
[![Build Status](https://travis-ci.com/linksplatform/Communication.svg?branch=master)](https://travis-ci.com/linksplatform/Communication)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/c25f708dc08b4f7e8d96c671378bb1ad)](https://app.codacy.com/app/drakonard/Communication?utm_source=github.com&utm_medium=referral&utm_content=linksplatform/Communication&utm_campaign=Badge_Grade_Dashboard)
[![CodeFactor](https://www.codefactor.io/repository/github/linksplatform/communication/badge)](https://www.codefactor.io/repository/github/linksplatform/communication)

# Communication
# [Communication](https://github.com/linksplatform/Communication)

LinksPlatform's Platform.Communication Class Library.

Namespace: Platform.Communication
Namespace: [Platform.Communication](https://linksplatform.github.io/Communication/api/Platform.Communication.html)

Forked from: [Konard/LinksPlatform/Platform/Platform.Communication](https://github.com/Konard/LinksPlatform/tree/0599b1bdad82c23ae80c890e63b309764b6997bd/Platform/Platform.Communication)

NuGet package: [Platform.Communication](https://www.nuget.org/packages/Platform.Communication)
NuGet package: [Platform.Communication](https://www.nuget.org/packages/Platform.Communication)

## [Documentation](https://linksplatform.github.io/Communication)
[PDF file](https://linksplatform.github.io/Communication/Platform.Communication.pdf) with code for e-readers.

## Depend on
* [Platform.Threading](https://github.com/linksplatform/Threading)
* [Platform.Singletons](https://github.com/linksplatform/Singletons)

## Dependent libraries
* [Platform.Data.Triplets](https://github.com/linksplatform/Data.Triplets)

## Mystery files
* [.travis.yml](https://github.com/linksplatform/Communication/blob/master/.travis.yml) - Travis CI build configuration.
* [docfx.json](https://github.com/linksplatform/Communication/blob/master/docfx.json) and [toc.yml](https://github.com/linksplatform/Communication/blob/master/toc.yml) - DocFX build configuration.
* [format-document.sh](https://github.com/linksplatform/Communication/blob/master/format-document.sh) - script for formating `tex` file for generating PDF from it.
* [format-csharp-files.py](https://github.com/linksplatform/Communication/blob/master/format-csharp-files.py) - script for formating single `.cs` file as a part of `tex` file.
* [generate-pdf.sh](https://github.com/linksplatform/Communication/blob/master/generate-pdf.sh) - script that generates PDF with code for e-readers.
* [publish-docs.sh](https://github.com/linksplatform/Communication/blob/master/publish-docs.sh) - script that publishes generated documentation and PDF with code for e-readers to `gh-pages` branch.
* [push-nuget.bat](https://github.com/linksplatform/Communication/blob/master/push-nuget.bat) - Windows script for publishing current version of NuGet package.
37 changes: 37 additions & 0 deletions docfx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"metadata": [
{
"src": [
{
"files": [ "**/*.sln" ],
"exclude": [ "**/bin/**", "**/obj/**" ],
"src": ""
}
],
"dest": "obj/api"
}
],
"build": {
"content": [
{
"files": [ "**/*.yml" ],
"src": "obj/api",
"dest": "api"
},
{
"files": [ "*.md", "toc.yml" ]
}
],
"globalMetadata": {
"_appTitle": "LinksPlatform's Platform.$TRAVIS_REPO_NAME Library",
"_enableSearch": true,
"_gitContribute": {
"branch": "master"
},
"_gitUrlPattern": "github"
},
"markdownEngineName": "markdig",
"dest": "_site",
"xrefService": [ "https://xref.docs.microsoft.com/query?uid={uid}" ]
}
}
19 changes: 19 additions & 0 deletions format-csharp-files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
for line in sys.stdin.readlines():
line = line.strip()
print "\\index{%s}" % (line.replace('_','\\_'))
print "\\begin{section}{%s}" % (line.replace('_','\\_'))
#print "\\inputminted[tabsize=2,breaklines,linenos=true]{csharp}{%s}" % (line)
print "\\begin{minted}[tabsize=2,breaklines,breakanywhere,linenos=true,xleftmargin=7mm,framesep=4mm]{csharp}"
f = open(line,"rt")
c = "\n".join([x.strip("\n") for x in f.readlines()])
f.close()
c = c.replace(u'\ufeff','')
print c
print "\\end{minted}"
print "\\end{section}"
print
53 changes: 53 additions & 0 deletions format-document.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash
set -e # Exit with nonzero exit code if anything fails

# Remove auto-generated code files
find ./Platform.${TRAVIS_REPO_NAME}/obj -type f -iname "*.cs" -delete
find ./Platform.${TRAVIS_REPO_NAME}.Tests/obj -type f -iname "*.cs" -delete

# Download fvextra package
wget https://raw.githubusercontent.com/gpoore/fvextra/cc1c0c5f7b92023cfec67084e2a87bdac520414c/fvextra/fvextra.sty

echo """
\\documentclass[11pt,a4paper,fleqn]{report}
\\usepackage[left=5mm,top=5mm,right=5mm,bottom=5mm]{geometry}
\\textwidth=200mm
\\usepackage[utf8]{inputenc}
\\usepackage[T1]{fontenc}
\\usepackage[T2A]{fontenc}
\\usepackage{fvextra}
\\usepackage{minted}
\\usemintedstyle{vs}
\\usepackage{makeidx}
\\usepackage[columns=1]{idxlayout}
\\makeindex
\\renewcommand{\\thesection}{\\arabic{chapter}.\\arabic{section}}
\\setcounter{chapter}{1}
\\setcounter{section}{0}
\\usepackage[tiny]{titlesec}
\\titlespacing\\chapter{0mm}{0mm}{0mm}
\\titlespacing\\section{0mm}{0mm}{0mm}
\\DeclareUnicodeCharacter{221E}{\\ensuremath{\\infty}}
\\DeclareUnicodeCharacter{FFFD}{\\ensuremath{ }}
\\usepackage{fancyhdr}
\\pagestyle{fancy}
\\fancyhf{}
\\fancyfoot[C]{\\thepage}
\\renewcommand{\\headrulewidth}{0mm}
\\renewcommand{\\footrulewidth}{0mm}
\\renewcommand{\\baselinestretch}{0.7}
\\begin{document}
\\sf
\\noindent{\\Large LinksPlatform's Platform.${TRAVIS_REPO_NAME} Class Library}
"""

# Project files
find ./Platform.${TRAVIS_REPO_NAME} -type f -iname '*.cs' | sort -b | python format-csharp-files.py

# Tests files
find ./Platform.${TRAVIS_REPO_NAME}.Tests -type f -iname '*.cs' | sort -b | python format-csharp-files.py

echo """
\\printindex
\\end{document}
"""
22 changes: 22 additions & 0 deletions generate-pdf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
set -e # Exit with nonzero exit code if anything fails

# Pull requests and commits to other branches shouldn't try to deploy, just build to verify
if [[ ( "$TRAVIS_PULL_REQUEST" != "false" ) || ( "$TRAVIS_BRANCH" != "$SOURCE_BRANCH" ) ]]; then
echo "Skipping pdf generation."
exit 0
fi

# Generate tex file
bash format-document.sh > document.tex

# Generate pdf
latex -shell-escape document.tex
makeindex document
latex -shell-escape document.tex
dvipdf document.dvi document.pdf
dvips document.dvi

# Copy pdf to publish location (with be used in the next script)
mkdir _site
cp document.pdf _site/Platform.${TRAVIS_REPO_NAME}.pdf
55 changes: 55 additions & 0 deletions publish-docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash
set -e # Exit with nonzero exit code if anything fails

# Pull requests and commits to other branches shouldn't try to deploy, just build to verify
if [[ ( "$TRAVIS_PULL_REQUEST" != "false" ) || ( "$TRAVIS_BRANCH" != "$SOURCE_BRANCH" ) ]]; then
echo "Skipping documentation deploy."
exit 0
fi

# Settings
TARGET_BRANCH="gh-pages"
SHA=$(git rev-parse --verify HEAD)
COMMIT_USER_NAME="linksplatform-docs"
COMMIT_USER_EMAIL="[email protected]"
REPOSITORY="github.com/linksplatform/${TRAVIS_REPO_NAME}"

# Insert repository name into DocFX's configuration files
sed -i "s/\$TRAVIS_REPO_NAME/${TRAVIS_REPO_NAME}/g" toc.yml
sed -i "s/\$TRAVIS_REPO_NAME/${TRAVIS_REPO_NAME}/g" docfx.json

# DocFX installation
nuget install docfx.console
mono $(echo ./*docfx.console.*)/tools/docfx.exe docfx.json

# Clone the existing gh-pages for this repo into out/
# Create a new empty branch if gh-pages doesn't exist yet (should only happen on first deply)
git clone https://$REPOSITORY out
cd out
git checkout $TARGET_BRANCH || git checkout --orphan $TARGET_BRANCH
cd ..

# Clean out existing contents
rm -rf out/**/* || exit 0

# Copy genereted docs site
cp -r _site/* out

cd out

# Do not use index.md
cp README.html index.html

# Now let's go have some fun with the cloned repo
git config user.name "$COMMIT_USER_NAME"
git config user.email "$COMMIT_USER_EMAIL"
git remote rm origin
git remote add origin https://$COMMIT_USER_NAME:$TOKEN@$REPOSITORY.git

# Commit the "changes", i.e. the new version.
# The delta will show diffs between new and old versions.
git add --all
git commit -m "Deploy to GitHub Pages: ${SHA}"

# Now that we're all set up, we can push.
git push https://$COMMIT_USER_NAME:$TOKEN@$REPOSITORY.git $TARGET_BRANCH
8 changes: 3 additions & 5 deletions push-nuget.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
dotnet pack -c Release
cd bin\Release\
nuget push -Source https://api.nuget.org/v3/index.json *.nupkg
del *.nupkg
del *.snupkg
cd ..\..
dotnet nuget push -s https://api.nuget.org/v3/index.json **/*.nupkg
del /s /q *.nupkg
del /s /q *.snupkg
5 changes: 5 additions & 0 deletions toc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- name: Home
href: README.md
- name: API Documentation
href: obj/api/
homepage: api/Platform.$TRAVIS_REPO_NAME.html

0 comments on commit ee135db

Please sign in to comment.