Skip to content

Commit

Permalink
restructure folder/ add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
goswinr committed Nov 1, 2024
1 parent 0d5e786 commit 32f5e25
Show file tree
Hide file tree
Showing 22 changed files with 1,482 additions and 93 deletions.
20 changes: 20 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": 1,
"isRoot": true,
"tools": {
"fable": {
"version": "4.23.0",
"commands": [
"fable"
],
"rollForward": false
},
"fsdocs-tool": {
"version": "20.0.1",
"commands": [
"fsdocs"
],
"rollForward": false
}
}
}
20 changes: 20 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: 2
updates:
# Update to newer version of GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"

# Update to newer NuGet dependencies
- package-ecosystem: "nuget"
directory: "/Src/"
schedule:
interval: "daily"
ignore:
- dependency-name: "FSharp.Core"

- package-ecosystem: "nuget"
directory: "/Tests/"
schedule:
interval: "daily"
28 changes: 28 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'

- name: Restore dependencies
run: dotnet restore

- name: Build solution
run: dotnet build --configuration Release --no-restore
54 changes: 54 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Docs

# copied and adapted from https://fsprojects.github.io/FSharp.Formatting/zero-to-hero.html#Ship-it

# Trigger this Action when new code is pushed to the main branch
on:
push:
branches:
- main

# We need some permissions to publish to Github Pages
permissions:
contents: write
pages: write
id-token: write

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Git Checkout source code
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x' # Adjust the version as needed


- name: Restore dotnet tools
run: dotnet tool restore

- name: Build code to make xml file
run: dotnet build -c Release # see required xml tags: https://fsprojects.github.io/FSharp.Formatting/zero-to-hero.html#Generating-API-documentation

- name: copy README.md to Docs/index.md
run: cp README.md Docs/index.md

- name: Generate the documentation html
run: dotnet fsdocs build --properties Configuration=Release --input Docs --output DocsGenerated

- name: Upload documentation html files
uses: actions/upload-pages-artifact@v3
with:
path: ./DocsGenerated

# GitHub Actions recommends deploying in a separate job.
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
47 changes: 47 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Test

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x' # Adjust the version as needed

- name: Restore dependencies
run: dotnet restore

- name: Run tests .NET
run: dotnet run
working-directory: ./Tests

# run JS tests:

- name: Restore .NET tools (Fable)
run: dotnet tool restore

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22.x' # Adjust the version as needed

- name: Clean Install npm dependencies
run: npm ci
working-directory: ./Tests

- name: Run tests JS
run: npm test
working-directory: ./Tests
13 changes: 10 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
.vs/
bin/
obj/
fable_modules/
node_modules/
package-lock.json
*.fs.js
*.fs.ts
js/
ts/
# *.js
# *.ts

# FSharp.Formatting
.fsdocs/
output/
tmp/
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [0.2.0] - 2024-10-30
### Changed
- Removed IDictionary and IEnumerable interface becaus not compatible with Fable JS & TS yet
- Unified API
### Fixed
- fixed ToString() members
### Added
- docs

## [0.1.0] - 2024-09-29
### Added
- Implementation ported from [FsEx](https://github.com/goswinr/FsEx)
- Added more tests


[Unreleased]: https://github.com/goswinr/Dicts/compare/0.2.0...HEAD
[0.2.0]: https://github.com/goswinr/Dicts/compare/0.1.0...0.2.0
[0.1.0]: https://github.com/goswinr/Dicts/releases/tag/0.1.0

<!--
use to get tag dates:
git log --tags --simplify-by-decoration --pretty="format:%ci %d"
-->

28 changes: 28 additions & 0 deletions Dicts.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Dicts", "Src\Dicts.fsproj", "{904EDDA5-07C9-49BD-8192-C66646C3507E}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Tests", "Tests\Tests.fsproj", "{FDDE2DDA-FE03-4E2C-85D1-9A7115DF0375}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{904EDDA5-07C9-49BD-8192-C66646C3507E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{904EDDA5-07C9-49BD-8192-C66646C3507E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{904EDDA5-07C9-49BD-8192-C66646C3507E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{904EDDA5-07C9-49BD-8192-C66646C3507E}.Release|Any CPU.Build.0 = Release|Any CPU
{FDDE2DDA-FE03-4E2C-85D1-9A7115DF0375}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FDDE2DDA-FE03-4E2C-85D1-9A7115DF0375}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FDDE2DDA-FE03-4E2C-85D1-9A7115DF0375}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FDDE2DDA-FE03-4E2C-85D1-9A7115DF0375}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
39 changes: 0 additions & 39 deletions Doc/READMEnuget.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[InternetShortcut]
URL=https://favicon.io/
Binary file added Docs/img/favicon.ico
Binary file not shown.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
51 changes: 36 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,41 @@

![Logo](https://raw.githubusercontent.com/goswinr/Dic/main/Doc/logo128.png)
# Dic
![Logo](https://raw.githubusercontent.com/goswinr/Dicts/main/Docs/img/logo128.png)
# Dicts

[![Dic on nuget.org](https://img.shields.io/nuget/v/Dic)](https://www.nuget.org/packages/Dic/)
[![Dic on fuget.org](https://www.fuget.org/packages/Dic/badge.svg)](https://www.fuget.org/packages/Dic)
![code size](https://img.shields.io/github/languages/code-size/goswinr/Dic.svg)
[![license](https://img.shields.io/github/license/goswinr/Dic)](LICENSE)
[![Dicts on nuget.org](https://img.shields.io/nuget/v/Dicts)](https://www.nuget.org/packages/Dicts/)
[![Build Status](https://github.com/goswinr/Dicts/actions/workflows/build.yml/badge.svg)](https://github.com/goswinr/Dicts/actions/workflows/build.yml)
[![Docs Build Status](https://github.com/goswinr/Dicts/actions/workflows/docs.yml/badge.svg)](https://github.com/goswinr/Dicts/actions/workflows/docs.yml)
[![Test Status](https://github.com/goswinr/Dicts/actions/workflows/test.yml/badge.svg)](https://github.com/goswinr/Dicts/actions/workflows/test.yml)
[![license](https://img.shields.io/github/license/goswinr/Dicts)](LICENSE.md)
![code size](https://img.shields.io/github/languages/code-size/goswinr/Dicts.svg)

A small F# library extending the .NET Dictionary
This F# library provides:
- A dedicated `Dict<'T>` type. It is a thin wrapper around `Dictionary<'T>` with more functionality and nicer Error messages.
- A `DefaultDict<'T>` type. It works like [Python's' defaultdict](https://docs.python.org/3/library/collections.html#collections.defaultdict).\
By providing a default function in the constructor it will always return a value for any key.
- Extension methods for working with the `IDictionary<'T>` interface.

### Test

### Example

```fsharp
#r "nuget: Dicts"
open Dicts
let dd = DefaultDict<string,int>(fun _ -> ref 99)
incr dd.["A"] // since dd.["A"] does not exist it will be created with the default value 99, and then incremented to 100
incr dd.["A"] // now it exists and will be incremented to 101
dd.["A"].Value = 101 // true
```

### Full API Documentation

[goswinr.github.io/Dicts](https://goswinr.github.io/Dicts/reference/Dicts.html)

### Tests
All Tests run in both javascript and dotnet.
go to the tests folder
Successful Fable compilation to typescript is verified too.
Go to the tests folder:

```bash
cd Tests
Expand All @@ -23,19 +47,16 @@ For testing with .NET using Expecto:
dotnet run
```

for testing with Fable.Mocha:
for JS testing with Fable.Mocha and TS verification:

```bash
npm test
```

### License
[MIT](https://raw.githubusercontent.com/goswinr/Dic/main/LICENSE.txt)
[MIT](https://raw.githubusercontent.com/goswinr/Dicts/main/LICENSE.txt)

### Changelog
`0.2.0`
- fix Fable compatibility
see [CHANGELOG.md](https://github.com/goswinr/Dicts/blob/main/CHANGELOG.md)

`0.1.0`
- ported from FsEx library

13 changes: 0 additions & 13 deletions Tests/.config/dotnet-tools.json

This file was deleted.

Loading

0 comments on commit 32f5e25

Please sign in to comment.