Skip to content

Commit 5d0a6c9

Browse files
committed
feat: add documentation
1 parent e089851 commit 5d0a6c9

File tree

144 files changed

+7177
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+7177
-0
lines changed

docs/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# @annotat3d/docs
2+
3+
## 0.1.1
4+
5+
### Patch Changes
6+
7+
- Versioning latest patch to docs and app and adding automated server.

docs/Dockerfile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Base image
2+
FROM node:18-alpine AS base
3+
ENV PNPM_HOME="/pnpm"
4+
ENV PATH="$PNPM_HOME:$PATH"
5+
RUN corepack enable
6+
7+
# Install dependencies
8+
FROM base AS deps
9+
RUN apk add --no-cache libc6-compat
10+
WORKDIR /app
11+
12+
# Copy over files and install dependencies
13+
COPY . .
14+
RUN pnpm install
15+
16+
# Build the app
17+
RUN pnpm run build
18+
19+
# Prepare for production
20+
FROM base AS runner
21+
WORKDIR /app
22+
23+
# Create nextjs user
24+
RUN addgroup --system --gid 1001 nodejs
25+
RUN adduser --system --uid 1001 nextjs
26+
27+
# Create necessary directories with proper permissions
28+
RUN mkdir -p /app/.next/cache/images && chown -R nextjs:nodejs /app/.next
29+
30+
# Set the user
31+
USER nextjs
32+
33+
# Copy the app files from deps stage
34+
COPY --from=deps /app ./
35+
36+
# Start the app
37+
CMD ["pnpm", "start"]
38+

docs/FilenameTester.js

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
"use client";
2+
3+
import React, { useState } from 'react';
4+
5+
function getRAFTVolumeInfoFromFilename(filename) {
6+
const pattern = /([a-zA-Z0-9_\.\/\-]+)[a-zA-Z_\.\/\-0-9]*[_|\-]([0-9]+)x([0-9]+)x([0-9]+)[a-zA-Z_\.\/\-0-9]*[_|\-]([0-9]+)[b|bits|bit]|\.(b|raw)/;
7+
const numpyPattern = /([a-zA-Z0-9_\.\/\-]+)[a-zA-Z_\.\/\-0-9]*[_|\-]([0-9]+)x([0-9]+)x([0-9]+)[a-zA-Z_\.\/\-0-9]*[_|\-](int8|uint8|int16|uint16|int32|uint32|float32|complex64)|\.(b|raw)/;
8+
9+
let xsize = null, ysize = null, zsize = null, dtype = null;
10+
11+
// First match the pattern with bit size, such as 32bits
12+
let match = filename.match(pattern);
13+
if (match !== null) {
14+
try {
15+
zsize = parseInt(match[4]);
16+
ysize = parseInt(match[3]);
17+
xsize = parseInt(match[2]);
18+
19+
// Convert bits to dtype
20+
const bits = parseInt(match[5]);
21+
if (bits === 8) dtype = 'uint8';
22+
else if (bits === 16) dtype = 'uint16';
23+
else if (bits === 32) dtype = 'float32';
24+
else if (bits === 64) dtype = 'complex64';
25+
} catch (e) {}
26+
}
27+
28+
// If xsize, ysize, zsize, or dtype is still null, use numpy-like pattern
29+
if (xsize === null || ysize === null || zsize === null || dtype === null) {
30+
match = filename.match(numpyPattern);
31+
if (match !== null) {
32+
try {
33+
zsize = parseInt(match[4]);
34+
ysize = parseInt(match[3]);
35+
xsize = parseInt(match[2]);
36+
dtype = match[5]; // directly matches int8, float32, etc.
37+
} catch (e) {}
38+
}
39+
}
40+
41+
return { xsize, ysize, zsize, dtype };
42+
}
43+
44+
export default function FilenameTester() {
45+
const [filename, setFilename] = useState('');
46+
const [result, setResult] = useState({ xsize: null, ysize: null, zsize: null, dtype: null });
47+
48+
const handleTest = () => {
49+
const info = getRAFTVolumeInfoFromFilename(filename);
50+
setResult(info);
51+
};
52+
53+
return (
54+
<div>
55+
<h3>Test Raw Parsing</h3>
56+
<input
57+
type="text"
58+
value={filename}
59+
onChange={(e) => setFilename(e.target.value)}
60+
placeholder="Enter filename"
61+
style={{ padding: '8px', fontSize: '16px', width: '300px', marginBottom: '10px', backgroundColor: '#cedaed' }}
62+
/>
63+
<br />
64+
<button
65+
onClick={handleTest}
66+
style={{
67+
padding: '10px 10px',
68+
backgroundColor: '#4CAF50',
69+
color: 'white',
70+
border: 'none',
71+
borderRadius: '5px',
72+
fontSize: '16px',
73+
cursor: 'pointer',
74+
transition: 'background-color 0.3s',
75+
}}
76+
onMouseOver={(e) => (e.target.style.backgroundColor = '#45a049')}
77+
onMouseOut={(e) => (e.target.style.backgroundColor = '#4CAF50')}
78+
>
79+
Test
80+
</button>
81+
<p>
82+
X size: {result.xsize}, Y size: {result.ysize}, Z size: {result.zsize}, data type: {result.dtype}
83+
</p>
84+
</div>
85+
);
86+
}

docs/README.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Project Setup Guide
2+
3+
This guide provides instructions for setting up and running the project locally without Docker.
4+
5+
## Prerequisites
6+
- Node.js 18+ (recommended to manage via nvm)
7+
- pnpm (package manager for Node.js)
8+
9+
## Installation
10+
11+
### Install nvm (Node Version Manager)
12+
13+
Using nvm allows for easy management of multiple Node.js versions.
14+
15+
#### Linux/macOS
16+
17+
1. Install nvm:
18+
```sh
19+
curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.4/install.sh | bash
20+
```
21+
22+
2. Restart your terminal or run:
23+
```sh
24+
source ~/.bashrc
25+
```
26+
27+
3. Install and use Node.js 18:
28+
```sh
29+
nvm install 18
30+
nvm use 18
31+
```
32+
33+
## Runnig the project locally
34+
35+
1. Clone the repository:
36+
```sh
37+
git clone <https://gitlab.cnpem.br/GCD/data-science/segmentation/annodocs.git>
38+
cd <annodocs>
39+
```
40+
41+
2. Install dependencies and build the project:
42+
```sh
43+
pnpm install
44+
pnpm run build
45+
```
46+
47+
### Development version
48+
49+
3. Start the development server:
50+
```sh
51+
pnpm dev
52+
```
53+
54+
4. Open the URL provided in the terminal (e.g., http://localhost:4321) in your browser.
55+
56+
### Production version
57+
3. Build the project for production:
58+
```sh
59+
pnpm build
60+
```
61+
62+
4. Determine your host IP address:
63+
```sh
64+
hostname -I
65+
```
66+
67+
5. Start the production server, specifying the host from the previous step and port of your choice:
68+
```sh
69+
PORT=4322 HOST=172.17.0.1 pnpm start
70+
```
71+
72+
4. Open the provided URL (e.g., http://172.17.0.1:4322) in your browser.
73+
74+
75+
## Learn More
76+
77+
For further information, refer to the following resources:
78+
79+
- [Next.js Documentation](https://nextjs.org/docs) – Learn about Next.js features and APIs.
80+
features and API.
81+
- [Learn Next.js](https://nextjs.org/learn) – Interactive Next.js tutorial.
82+
- [Fumadocs](https://fumadocs.vercel.app) – Interactive Next.js tutorial.

0 commit comments

Comments
 (0)