Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 12ef40d

Browse files
authored
docs via ssh (#751)
* Update docs-deploy.yml * Update _axes.py * Update docs-deploy.yml * Update docs-deploy.yml
1 parent 3362669 commit 12ef40d

File tree

2 files changed

+29
-130
lines changed

2 files changed

+29
-130
lines changed

.github/workflows/docs-deploy.yml

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,20 @@ jobs:
6868
if: ${{ github.ref == 'refs/heads/main' }}
6969
# any push to main goes to fastplotlib.org/ver/dev
7070
run: echo "DOCS_VERSION_DIR=dev" >> "$GITHUB_ENV"
71-
72-
# upload docs via FTP
71+
72+
# upload docs via SCP
7373
- name: Deploy docs
74-
uses: SamKirkland/[email protected]
74+
uses: appleboy/[email protected]
7575
with:
76-
server: ${{ secrets.DOCS_SERVER }}
76+
host: ${{ secrets.DOCS_SERVER }}
7777
username: ${{ secrets.DOCS_USERNAME }}
78-
password: ${{ secrets.DOCS_PASSWORD }}
79-
# built docs
80-
local-dir: docs/build/html/
81-
# output subdir based on the previous if statements
82-
server-dir: ./ver/${{ env.DOCS_VERSION_DIR }}/
78+
port: ${{ secrets.DOCS_PORT }}
79+
key: ${{ secrets.DOCS_KEY }}
80+
passphrase: ${{ secrets.DOCS_PASS }}
81+
source: "docs/build/html/*"
82+
# without strip_components it creates dirs docs/build/html within /ver on the server
83+
strip_components: 3
84+
target: /home/${{ secrets.DOCS_USERNAME }}/public_html/ver/${{ env.DOCS_VERSION_DIR }}/
8385

8486
# comment on PR to provide link to built docs
8587
- name: Add PR link in comment
@@ -88,19 +90,18 @@ jobs:
8890
with:
8991
message: |
9092
📚 Docs preview built and uploaded! https://www.fastplotlib.org/ver/${{ env.DOCS_VERSION_DIR }}
91-
92-
# also deploy to root if this is a new release
93-
# i.e., fastplotlib.org/ points to docs for the latest release
94-
- name: Deploy docs
93+
94+
# upload docs via SCP
95+
- name: Deploy docs release
9596
if: ${{ github.ref_type == 'tag' }}
96-
uses: SamKirkland/[email protected]
97+
uses: appleboy/[email protected]
9798
with:
98-
server: ${{ secrets.DOCS_SERVER }}
99+
host: ${{ secrets.DOCS_SERVER }}
99100
username: ${{ secrets.DOCS_USERNAME }}
100-
password: ${{ secrets.DOCS_PASSWORD }}
101-
log-level: verbose
102-
timeout: 60000
103-
local-dir: docs/build/html/
104-
server-dir: ./ # deploy to the root dir
105-
exclude: | # don't delete the /ver/ dir
106-
**/ver/**
101+
port: ${{ secrets.DOCS_PORT }}
102+
key: ${{ secrets.DOCS_KEY }}
103+
passphrase: ${{ secrets.DOCS_PASS }}
104+
source: "docs/build/html/*"
105+
# without strip_components it creates dirs docs/build/html within /ver on the server
106+
strip_components: 3
107+
target: /home/${{ secrets.DOCS_USERNAME }}/public_html/

fastplotlib/graphics/_axes.py

Lines changed: 6 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -141,108 +141,6 @@ def yz(self) -> Grid:
141141
return self._yz
142142

143143

144-
class Ruler(pygfx.Ruler):
145-
def __init__(self, **kwargs):
146-
super().__init__(**kwargs)
147-
self.tick_text_mapper = None
148-
self.font_size = 14
149-
150-
def _update_sub_objects(self, ticks, tick_auto_step):
151-
"""Update the sub-objects to show the given ticks."""
152-
assert isinstance(ticks, dict)
153-
154-
tick_size = 5
155-
min_n_slots = 8 # todo: can be (much) higher when we use a single text object!
156-
157-
# Load config
158-
start_pos = self._start_pos
159-
end_pos = self._end_pos
160-
start_value = self._start_value
161-
end_value = self.end_value
162-
163-
# Derive some more variables
164-
length = end_value - start_value
165-
vec = end_pos - start_pos
166-
if length:
167-
vec /= length
168-
169-
# Get array to store positions
170-
n_slots = self.points.geometry.positions.nitems
171-
n_positions = len(ticks) + 2
172-
if n_positions <= n_slots <= max(min_n_slots, 2 * n_positions):
173-
# Re-use existing buffers
174-
positions = self.points.geometry.positions.data
175-
sizes = self.points.geometry.sizes.data
176-
self.points.geometry.positions.update_range()
177-
self.points.geometry.sizes.update_range()
178-
else:
179-
# Allocate new buffers
180-
new_n_slots = max(min_n_slots, int(n_positions * 1.2))
181-
positions = np.zeros((new_n_slots, 3), np.float32)
182-
sizes = np.zeros((new_n_slots,), np.float32)
183-
self.points.geometry.positions = pygfx.Buffer(positions)
184-
self.points.geometry.sizes = pygfx.Buffer(sizes)
185-
# Allocate text objects
186-
while len(self._text_object_pool) < new_n_slots:
187-
ob = pygfx.Text(
188-
pygfx.TextGeometry("", screen_space=True, font_size=self.font_size),
189-
pygfx.TextMaterial(aa=False),
190-
)
191-
self._text_object_pool.append(ob)
192-
self._text_object_pool[new_n_slots:] = []
193-
# Reset children
194-
self.clear()
195-
self.add(self._line, self._points, *self._text_object_pool)
196-
197-
def define_text(pos, text):
198-
if self.tick_text_mapper is not None and text != "":
199-
text = self.tick_text_mapper(text)
200-
201-
ob = self._text_object_pool[index]
202-
ob.geometry.anchor = self._text_anchor
203-
ob.geometry.anchor_offset = self._text_anchor_offset
204-
ob.geometry.set_text(text)
205-
ob.local.position = pos
206-
207-
# Apply start point
208-
index = 0
209-
positions[0] = start_pos
210-
if self._ticks_at_end_points:
211-
sizes[0] = tick_size
212-
define_text(start_pos, f"{self._start_value:0.4g}")
213-
else:
214-
sizes[0] = 0
215-
define_text(start_pos, f"")
216-
217-
# Collect ticks
218-
index += 1
219-
for value, text in ticks.items():
220-
pos = start_pos + vec * (value - start_value)
221-
positions[index] = pos
222-
sizes[index] = tick_size
223-
define_text(pos, text)
224-
index += 1
225-
226-
# Handle end point, and nullify remaining slots
227-
positions[index:] = end_pos
228-
sizes[index:] = 0
229-
for ob in self._text_object_pool[index:]:
230-
ob.geometry.set_text("")
231-
232-
# Show last tick?
233-
if self._ticks_at_end_points:
234-
sizes[index] = tick_size
235-
define_text(end_pos, f"{end_value:0.4g}")
236-
237-
# Hide the ticks close to the ends?
238-
if self._ticks_at_end_points and ticks:
239-
tick_values = list(ticks.keys())
240-
if abs(tick_values[0] - start_value) < 0.5 * tick_auto_step:
241-
self._text_object_pool[1].geometry.set_text("")
242-
if abs(tick_values[-1] - end_value) < 0.5 * tick_auto_step:
243-
self._text_object_pool[index - 1].geometry.set_text("")
244-
245-
246144
class Axes:
247145
def __init__(
248146
self,
@@ -283,9 +181,9 @@ def __init__(
283181
}
284182

285183
# create ruler for each dim
286-
self._x = Ruler(**x_kwargs)
287-
self._y = Ruler(**y_kwargs)
288-
self._z = Ruler(**z_kwargs)
184+
self._x = pygfx.Ruler(**x_kwargs)
185+
self._y = pygfx.Ruler(**y_kwargs)
186+
self._z = pygfx.Ruler(**z_kwargs)
289187

290188
self._offset = offset
291189

@@ -400,17 +298,17 @@ def offset(self, value: np.ndarray):
400298
self._offset = value
401299

402300
@property
403-
def x(self) -> Ruler:
301+
def x(self) -> pygfx.Ruler:
404302
"""x axis ruler"""
405303
return self._x
406304

407305
@property
408-
def y(self) -> Ruler:
306+
def y(self) -> pygfx.Ruler:
409307
"""y axis ruler"""
410308
return self._y
411309

412310
@property
413-
def z(self) -> Ruler:
311+
def z(self) -> pygfx.Ruler:
414312
"""z axis ruler"""
415313
return self._z
416314

0 commit comments

Comments
 (0)