Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgraded the documentation to use the latest docfx tool #1143

Merged
merged 8 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 39 additions & 38 deletions .github/workflows/builddocs.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,48 @@
# GitHub workflow file under .github/workflows/
name: DocBuild

# Trigger the action on push to master
on:
push:
branches: master
branches:
- master

defaults:
run:
shell: bash
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
build_docs:
publish-docs:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: windows-latest
steps:
- name: Checkout master
uses: actions/checkout@v2
with:
path: main
- name: Get last commit message
run: |
cd main
echo "LAST_COMMIT=$(echo `git log -1 --pretty=%B`)" >> $GITHUB_ENV
cd ..
- name: Checkout gh-pages
uses: actions/checkout@v2
with:
ref: gh-pages
path: doc
- name: Install requirements
run: choco install docfx -y
- name: Build documentation
run: |
echo `pwd`
cd main
docfx docfx.json
cd ../doc
git config --global core.autocrlf false
git config --global user.email "[email protected]"
git config --global user.name "CI Build"
cp -r ../main/_site/* .
git add -A
if [ `git status -s | wc -l` = 0 ]; then
echo "No changes in built documentation, skipping"
exit 0
fi
git commit -m "$LAST_COMMIT" -q
git push origin gh-pages -q
- name: Checkout
uses: actions/checkout@v4
- name: Dotnet Setup
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x

- run: dotnet tool update -g docfx
- run: docfx Docs/docfx.json

- name: Setup Pages
uses: actions/configure-pages@v4
mrbean-bremen marked this conversation as resolved.
Show resolved Hide resolved
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
# Upload entire repository
path: 'Docs/_site'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
9 changes: 9 additions & 0 deletions Docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
###############
# folder #
###############
/**/DROP/
/**/TEMP/
/**/packages/
/**/bin/
/**/obj/
_site
20 changes: 20 additions & 0 deletions Docs/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
![W3C SVG Logo](https://www.w3.org/Icons/SVG/svg-logo-v.png)
mrbean-bremen marked this conversation as resolved.
Show resolved Hide resolved
## SVG.NET

Public fork of the C# SVG rendering library on CodePlex (now out of service).

This started out as a private fork by [vvvv](https://vvvv.org) with some minor modification to enable the writing of proper SVG strings.
After almost two years of fixes and improvements the company decided to share the codebase with the public in order to improve it even further.
In 2021, the repository has been transferred from the company organization `vvvv` to the new organization `svg-net` (e.g. SVG.NET).

Please feel free to fork it and open pull requests for any fix, improvement or feature you want to add.
You may check the [contributing guide](https://github.com/svg-net/SVG/blob/master/CONTRIBUTING.md) for more information on how to do this.

## License
Licensed under the [MS-PL license](https://github.com/svg-net/SVG?tab=MS-PL-1-ov-file),

This project has dependencies on other open-source projects. These projects are referenced via NuGet packages and might be subject to different licenses.

|Project|Author|Sources|License|
|--------|-----|---|---------|
|ExCSS|Tyler Brinks (@tylerbrinks)|[GitHub](https://github.com/TylerBrinks/ExCSS)|[MIT](https://github.com/TylerBrinks/ExCSS/blob/master/license.txt)|
5 changes: 5 additions & 0 deletions Docs/api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
###############
# temp file #
###############
*.yml
.manifest
27 changes: 27 additions & 0 deletions Docs/api/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# API Reference

## [](#namespaces)Namespaces
mrbean-bremen marked this conversation as resolved.
Show resolved Hide resolved

#### [Svg](xref:Svg)
[!include[](../namespaces/Svg.md)]

#### [Svg.DataTypes](xref:Svg.DataTypes)
[!include[](../namespaces/Svg.DataTypes.md)]

#### [Svg.Exceptions](xref:Svg.Exceptions)
[!include[](../namespaces/Svg.Exceptions.md)]

#### [Svg.ExtensionMethods](xref:Svg.ExtensionMethods)
[!include[](../namespaces/Svg.ExtensionMethods.md)]

#### [Svg.FilterEffects](xref:Svg.FilterEffects)
[!include[](../namespaces/Svg.FilterEffects.md)]

#### [Svg.Pathing](xref:Svg.Pathing)
[!include[](../namespaces/Svg.Pathing.md)]

#### [Svg.Transforms](xref:Svg.Transforms)
[!include[](../namespaces/Svg.Transforms.md)]



47 changes: 24 additions & 23 deletions doc/Q&A.md → Docs/articles/Faq.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Q & A
This is currently a collection of answered questions in issues that have been closed meanwhile.
The format of the page is preliminary and maybe changed if more questions accumulate.
The format of the page is preliminary and may be changed, if more questions accumulate.

## How to get started
Please use our [getting started article](http://svg-net.github.io/SVG/doc/GettingStarted.html) to get started with installation and implementation of the SVG library.
Expand All @@ -8,19 +9,19 @@ Please use our [getting started article](http://svg-net.github.io/SVG/doc/Gettin

(from [#327](https://github.com/svg-net/SVG/issues/327), by @flemingtech)

The rendering type plays a significant role on rendering speeds. For example, if anti-aliasing is off for the SvgDocument render times are notably faster.
The rendering type plays a significant role on rendering speeds. For example, if anti-aliasing is off for the `SvgDocument` render times are notably faster.

Because of the huge reduction in image quality, this wasn't a viable solution for my needs. Instead what I've come up with so far seems to work since I can't figure out how to get clipping regions to work.
Because of the huge reduction in image quality, this wasn't a viable solution for my needs. Instead, what I've come up with so far seems to work since I can't figure out how to get clipping regions to work.

After I load the SVG, I make new SVG with the same initial SvgDocument properties (basically a deep copy followed by deleting all children). As I walk the first document tree I'm looking for elements I know are going to be modified. For each one that I find, I remove it from the first SVG and put it into the 2nd SVG. When I'm doing this, I also apply any parent transforms to the new child since it doesn't need/have all of it's parents.
After I load the SVG, I make new SVG with the same initial `SvgDocumen`t properties (basically a deep copy followed by deleting all children). As I walk the first document tree I'm looking for elements I know are going to be modified. For each one that I find, I remove it from the first SVG and put it into the 2nd SVG. When I'm doing this, I also apply any parent transforms to the new child since it doesn't need/have all of its parents.

Once I'm done, I render the first SVG to an Image. When any of the 'animating' elements are changed, the 2nd SVG is rendered on top of a copy of the first SVG's rendering to form a complete composite. This prevents all the non-moving elements for having to re-render, unless of course the target graphics width/height changes. This is giving huge performance gains.
Once I'm done, I render the first SVG to an `Image`. When any of the 'animating' elements are changed, the 2nd SVG is rendered on top of a copy of the first SVG's rendering to form a complete composite. This prevents all the non-moving elements for having to re-render, unless of course the target graphics width/height changes. This is giving huge performance gains.

## Can I use SVG.NET in a UWP Windows 10 App?

(from [#219](https://github.com/svg-net/SVG/issues/219), by @jonthysell)

SVG.NET requires the System.Drawing namespace, which is not available in UWP. See http://stackoverflow.com/questions/31545389/windows-universal-app-with-system-drawing-and-possible-alternative.
SVG.NET requires the `System.Drawing` namespace, which is not available in UWP. See http://stackoverflow.com/questions/31545389/windows-universal-app-with-system-drawing-and-possible-alternative.

## How to render an SVG image to a single-color bitmap image?

Expand Down Expand Up @@ -68,19 +69,19 @@ Use `SvgDocument.Draw(int rasterWidth, int rasterHeight)`. If one of the values

(from [#381](https://github.com/svg-net/SVG/issues/381), by @rangercej, answered by @gvheertum)

I used it in server side code (ASP.NET MVC application and API's) and never had any problems with it. There is however be possible issues regarding use in services and API's, for example the System.Drawing might not always be available in certain situations (if I am not mistaken, some Azure service will not provide the System.Drawing since it relies on GDI calls) and will also be an issue when using it as "portable" code for example in .NET standard or .NET core (but I believe the library is already working on a migration/compatibility with .NET core/standard).
I used it in server side code (ASP.NET MVC application and APIs) and never had any problems with it. There are however possible issues regarding the use in services and APIs, for example `System.Drawing` might not always be available in certain situations (if I am not mistaken, some Azure service will not provide `System.Drawing` since it relies on GDI calls) and will also be an issue when using it as "portable" code for example in .NET standard or .NET core (but I believe the library is already working on a migration/compatibility with .NET core/standard).

So issues when using System.Drawing are indeed possible when using in a non interactive scenario, since most non-interactive code will often be functioning as service or API, meaning a lot of synchronous calls are possible, which opens a world of possible problems compared to an interactive app which you often only have a few instances loaded. System.Drawing can (and often will) be resource-heavy, so having a lot of synchronous processes will possibly have a huge impact on the performance. So I guess, that is why Microsoft warns about the usage. Rendering a large complex SVG to a big bitmap (eg 5000x5000px) will put a large load on the server, doing this in parallel might cause issues in performance and availability.
So issues when using `System.Drawing` are indeed possible when using in a non-interactive scenario, since most non-interactive code will often be functioning as service or API, meaning a lot of synchronous calls are possible, which opens a world of possible problems compared to an interactive app which you often only have a few instances loaded. `System.Drawing` can (and often will) be resource-heavy, so having a lot of synchronous processes will possibly have a huge impact on the performance. So I guess, that is why Microsoft warns about the usage. Rendering a large complex SVG to a big bitmap (eg 5000x5000px) will put a large load on the server, doing this in parallel might cause issues in performance and availability.

System.Drawing was initially not really created for service usage, so you *can* use it, but really need to be aware of possible issues. For example, see this article: https://photosauce.net/blog/post/5-reasons-you-should-stop-using-systemdrawing-from-aspnet
`System.Drawing` was initially not really created for service usage, so you *can* use it, but really need to be aware of possible issues. For example, see this article: https://photosauce.net/blog/post/5-reasons-you-should-stop-using-systemdrawing-from-aspnet

I believe there are some parallelisation tests in the UnitTest suite, since the SVG component did have some concurrency issues in the past. The parallelisation tests show that some parallel work is possible, but upping the limit will show you that resource issues are to be expected under large loads. When failing, System.Drawing will often not fail gracefully, but will often crash with some meaningless error (which makes debugging pretty hard sometimes).
I believe there are some parallelization tests in the UnitTest suite, since the SVG component did have some concurrency issues in the past. The parallelization tests show that some parallel work is possible, but upping the limit will show you that resource issues are to be expected under large loads. When failing, `System.Drawing` will often not fail gracefully, but will often crash with some meaningless error (which makes debugging pretty hard sometimes).

## How to change the SvgUnit DPI?

(from [#313](https://github.com/svg-net/SVG/issues/313), by @KieranSmartMP)

`SvgUnit` takes the DPI (which is called `Ppi` here) from the document. This is set to the system DPI at creation time, but can be set to another value afterwards, e.g.
`SvgUnit` takes the DPI (which is called `Ppi` here) from the document. This is set to the system DPI at creation time, but can be set to another value afterward, e.g.
```c#
doc = SvgDocument();
doc.Ppi = 200;
Expand All @@ -106,37 +107,37 @@ Custom attributes are publicly accessible as a collection, you can add an attrib

(see [#494](https://github.com/svg-net/SVG/pull/495#issuecomment-505429874), by @ErlendSB)

This happens if libgdiplus is not installed under Linux or MacOs - libgdiplus is need for the implementation of System.Drawing.Common. The system will validate gdi+ capabilities when calling SvgDocument.Open(), if the gdi+ capabilities are not available, you will receive a SvgGdiPlusCannotBeLoadedException.
This happens if `libgdiplus` is not installed under Linux or macOs - `libgdiplus` is needed for the implementation of `System.Drawing.Common`. The system will validate gdi+ capabilities when calling SvgDocument.Open(), if the gdi+ capabilities are not available, you will receive a SvgGdiPlusCannotBeLoadedException.

There is a [packaging project on Github](https://github.com/CoreCompat/libgdiplus-packaging) that helps installing that, here are the installation instructions (copied here for convenience):
There is a [packaging project on Github](https://github.com/CoreCompat/libgdiplus-packaging) that helps to install that, here are the installation instructions (copied here for convenience):

Older versions of the package threw a NullReferenceException when calling the SvgDocument.Open function. The cause of these errors was the same. Newer releases (since version 3.0), will yield a more descriptive exception as described above.
Older versions of the package threw a `NullReferenceException` when calling the `SvgDocument.Open` function. The cause of these errors was the same. Newer releases (since version 3.0), will yield a more descriptive exception as described above.

### Using libgdiplus on Ubuntu Linux
### Using `libgdiplus` on Ubuntu Linux

You can install libgdiplus on Ubuntu Linux using the Quamotion PPA. Follow these steps:
```
You can install `libgdiplus` on Ubuntu Linux using the Quamotion PPA. Follow these steps:
```bash
sudo add-apt-repository ppa:quamotion/ppa
sudo apt-get update
sudo apt-get install -y libgdiplus
```
### Using libgdiplus on macOS

On macOS, add a reference to the runtime.osx.10.10-x64.CoreCompat.System.Drawing package:
On macOS, add a reference to the `runtime.osx.10.10-x64.CoreCompat.System.Drawing` package:

```dotnet add package runtime.osx.10.10-x64.CoreCompat.System.Drawing```

When building from source-code you can also uncomment the
```
When building from source code you can also uncomment the
```xml
<!-- <ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<PackageReference Include="runtime.osx.10.10-x64.CoreCompat.System.Drawing" Version="5.6.20" />
</ItemGroup> -->
```
block in the Svg.csproj file.
block in the `Svg.csproj` file.

### Validating GDI+ capabilities

If you want to make sure the executing system is capable of using the GDI+ features, you can use one of the functions available on the SvgDocument class.
If you want to make sure the executing system is capable of using the GDI+ features, you can use one of the functions available in the `SvgDocument` class.

If you only want to get a boolean telling whether the capabilities are available, please use the following code:
```
Expand All @@ -147,4 +148,4 @@ If you want to ensure the capabilities and let an error be thrown when these are
```
SvgDocument.EnsureSystemIsGdiPlusCapable();
```
This function will throw a SvgGdiPlusCannotBeLoadedException if the capabilities are not available.
This function will throw a `SvgGdiPlusCannotBeLoadedException` if the capabilities are not available.
10 changes: 6 additions & 4 deletions doc/GettingStarted.md → Docs/articles/GettingStarted.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Getting Started

## Getting the library

Depending on the way you want to work with the library you can get the SVG library via NuGet, or roll your own binary from the sources or a personal fork of the sources.
Expand Down Expand Up @@ -53,11 +55,11 @@ The library depends on GDI+ (see also [here](http://svg-net.github.io/SVG/doc/Q&
.NET Core does not support GDI+ out of the box for non-Windows systems. For Mac and Linux you need to add a special compatibility package.
This is not included in the packages by default, since this would break rendering on Windows systems.

I you distribute your application as platform independent, you might want to add the following instructions (or a reference to this guide)
If you distribute your application as platform independent, you might want to add the following instructions (or a reference to this guide)
in your installation instructions to aid Mac and Linux users that want to utilize your application/library.

### Linux (Ubuntu)
For Linux you need to install `libgdiplus` from the `quamotion/ppa` feed on your machine/container:
For Linux, you need to install `libgdiplus` from the `quamotion/ppa` feed on your machine/container:
```
sudo add-apt-repository ppa:quamotion/ppa
sudo apt-get update
Expand Down Expand Up @@ -97,9 +99,9 @@ dotnet add reference SVG/sources/Svg.csproj
This approach will also take over all references required to the target project (e.g. when you added the `CoreCompat` package for Mac).
This will also compile the Svg sources when you build your own project, which might be useful if you plan to make changes in the Svg project yourself.

If you don't want to reference the project, you can get the `Svg.dll` file from the outpot folders after you compiled the project with the steps outlined above and reference it.
If you don't want to reference the project, you can get the `Svg.dll` file from the output folders after you compiled the project with the steps outlined above and reference it.
The Svg library does not utilize other external references under Windows, and by only using the `Svg.dll` file you will be able to use the library.
However please keep in mind that the Mac and Linux versions require additional tooling/packages.
However, please keep in mind that the Mac and Linux versions require additional tooling/packages.

## Using the library (examples)
This part will be extended in the future, for now please refer to the [Q&A](http://svg-net.github.io/SVG/doc/Q&A.html) for examples of how to use the library.
Expand Down
Loading