Skip to content

Commit

Permalink
Initial code commit, forked from: https://github.com/LinksPlatform/He…
Browse files Browse the repository at this point in the history
  • Loading branch information
Konard committed Aug 15, 2019
1 parent 97c0502 commit 0fd86a4
Show file tree
Hide file tree
Showing 14 changed files with 356 additions and 1 deletion.
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
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
after_success:
- bash ./generate-pdf.sh
- bash ./publish-docs.sh
17 changes: 17 additions & 0 deletions Counter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Runtime.CompilerServices;

#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

namespace Platform.Counters
{
/// <remarks>
/// Must be class, not struct (in order to persist access to Count field value).
/// </remarks>
public class Counter
{
protected ulong _count;
public ulong Count => _count;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Increment() => _count++;
}
}
30 changes: 30 additions & 0 deletions Counter[TValue, TDecision].cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System.Runtime.CompilerServices;

#pragma warning disable IDE0060 // Remove unused parameter
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

namespace Platform.Counters
{
public class Counter<TValue, TDecision> : Counter
{
private readonly TDecision _trueValue;

public Counter(TDecision trueValue) => _trueValue = trueValue;

public Counter() { }

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public TDecision IncrementAndReturnTrue()
{
_count++;
return _trueValue;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public TDecision IncrementAndReturnTrue(TValue value)
{
_count++;
return _trueValue;
}
}
}
24 changes: 24 additions & 0 deletions Counter[TValue].cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System.Runtime.CompilerServices;

#pragma warning disable IDE0060 // Remove unused parameter
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

namespace Platform.Counters
{
public class Counter<TValue> : Counter
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool IncrementAndReturnTrue()
{
_count++;
return true;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool IncrementAndReturnTrue(TValue value)
{
_count++;
return true;
}
}
}
27 changes: 27 additions & 0 deletions Platform.Counters.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Description>LinksPlatform's Platform.Counters Class Library</Description>
<Copyright>Konstantin Diachenko</Copyright>
<AssemblyTitle>Platform.Counters</AssemblyTitle>
<VersionPrefix>0.0.1</VersionPrefix>
<Authors>Konstantin Diachenko</Authors>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>Platform.Counters</AssemblyName>
<PackageId>Platform.Counters</PackageId>
<PackageTags>LinksPlatform;Counters;</PackageTags>
<PackageIconUrl>https://raw.githubusercontent.com/linksplatform/Documentation/18469f4d033ee9a5b7b84caab9c585acab2ac519/doc/Avatar-rainbow-icon-64x64.png</PackageIconUrl>
<PackageProjectUrl>https://linksplatform.github.io/Counters</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>git://github.com/linksplatform/Counters</RepositoryUrl>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<PackageReleaseNotes>Initial release.</PackageReleaseNotes>
</PropertyGroup>

</Project>
25 changes: 25 additions & 0 deletions Platform.Counters.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29209.62
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Platform.Counters", "Platform.Counters.csproj", "{33387358-3CDE-4A70-84F8-4C7E5E2DC42B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{33387358-3CDE-4A70-84F8-4C7E5E2DC42B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{33387358-3CDE-4A70-84F8-4C7E5E2DC42B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{33387358-3CDE-4A70-84F8-4C7E5E2DC42B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{33387358-3CDE-4A70-84F8-4C7E5E2DC42B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B5D9906D-4D99-4755-8DAB-A1770E132736}
EndGlobalSection
EndGlobal
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
# Counters
[![Build Status](https://travis-ci.com/linksplatform/Counters.svg?branch=master)](https://travis-ci.com/linksplatform/Counters)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/f095ae6c0742405399a34ad50ec6ab8d)](https://app.codacy.com/app/drakonard/Counters?utm_source=github.com&utm_medium=referral&utm_content=linksplatform/Counters&utm_campaign=Badge_Grade_Dashboard)
[![CodeFactor](https://www.codefactor.io/repository/github/linksplatform/Counters/badge)](https://www.codefactor.io/repository/github/linksplatform/Counters)

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

LinksPlatform's Platform.Counters Class Library.

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

Forked from: [LinksPlatform/Helpers/Counters](https://github.com/linksplatform/Helpers/tree/e27f7586f8015cad596b6aa3c2df2ac2a3dadb60/Counters)

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

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

## Mystery files
* [.travis.yml](https://github.com/linksplatform/Counters/blob/master/.travis.yml) - Travis CI build configuration.
* [docfx.json](https://github.com/linksplatform/Counters/blob/master/docfx.json) and [toc.yml](https://github.com/linksplatform/Counters/blob/master/toc.yml) - DocFX build configuration.
* [format-document.sh](https://github.com/linksplatform/Counters/blob/master/format-document.sh) - script for formating `tex` file for generating PDF from it.
* [format-csharp-files.py](https://github.com/linksplatform/Counters/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/Counters/blob/master/generate-pdf.sh) - script that generates PDF with code for e-readers.
* [publish-docs.sh](https://github.com/linksplatform/Counters/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/Counters/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
50 changes: 50 additions & 0 deletions format-document.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash
set -e # Exit with nonzero exit code if anything fails

# 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}
"""

# Remove auto-generated code files
find ./obj -type f -iname "*.cs" -delete

# CSharp files
#find * -type f -iname '*.cs' -exec sh -c 'enconv "{}"' \;
find . -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 $(ls | grep "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
6 changes: 6 additions & 0 deletions push-nuget.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dotnet pack -c Release
cd bin\Release\
nuget push -Source https://api.nuget.org/v3/index.json *.nupkg
del *.nupkg
del *.snupkg
cd ..\..
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 0fd86a4

Please sign in to comment.