Skip to content

Minor tweaks in README, others #102

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 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
9 changes: 5 additions & 4 deletions LCSC-API.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# LCSC API

- to get a product page based on LCSC number use GET request on
1. To get a product page based on LCSC number, use GET request on
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for making this numeric list? There isn't a clear sequence "first this and then this". The bullets serve as a clear graphical division between two parts of the text.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Numerical lists allow for discussion among teams better, which is important for software like this which may be prone to forking/external use. Either a short subheading or ordered list is most appropriate here, in my opinion.

Am happy to revert the list type change, if requested.

`https://lcsc.com/api/global/additional/search?q=<part_number>`. You get a
JSON with URL of the product.
- to get a product options based on LSCS number use POST request to
2. To get a product options based on LSCS number, use POST request to
`https://lcsc.com/api/products/search` with data
`current_page=1&in_stock=false&is_RoHS=false&show_icon=false&search_content=<part_number>`
`current_page=1&in_stock=false&is_RoHS=false&show_icon=false&search_content=<part_number>`.
You have to include CSRF token and cookies. Both you can get from the category
page (e.g., `https://lcsc.com/products/Pre-ordered-Products_11171.html`)
page (e.g., `https://lcsc.com/products/Pre-ordered-Products_11171.html`).

53 changes: 29 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
![Logo](web/public/favicon.svg)

# JLC PCB SMD Assembly Component Catalogue
# JLCPCB SMD Assembly Component Catalogue

A better tool to browse the components offered by the [JLC PCB SMT Assembly
A better tool to browse the components offered by the [JLCPCB SMT Assembly
Service](https://jlcpcb.com/smt-assembly).

## How To Use It?

Just visit: [https://yaqwsx.github.io/jlcparts/](https://yaqwsx.github.io/jlcparts/)

The site and parts cache is hosted on GitHub Pages.

Comment on lines +12 to +13
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment makes no logical sense here. This is the first information the user (e.g., electrical engineer) sees when using this project. Why should they care about the internal implementation details of the project? This just clutters the text for them.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should factor the whole ## Developer section out then. As a developer trying to contribute to this project, I had an embarassingly tough time figuring out how to get started.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that having a separate dev section is a good direction.

## Why?

Probably all of us love JLC PCB SMT assembly service. It is easy to use, cheap
Probably all of us love JLCPCB SMT assembly service. It is easy to use, cheap
and fast. However, you can use only components from [their
catalogue](https://jlcpcb.com/parts). This is not as bad, since the library is
quite broad. However, the library UI sucks. You can only browse the categories,
do full-text search. You cannot do parametric search nor sort by property.
quite broad. However, the library UI sucks. You can only browse the categories and do full-text searches. You cannot do parametric search nor sort by property.

That's why I created a simple page which presents the catalogue in much nicer
form. You can:
- do full-text search
- browse categories
- parametric search
- sort by any component attribute
- sort by price based on quantity
- easily access datasheet and LCSC product page.
- easily access datasheet and LCSC product page

## Do You Enjoy It? Does It Make Your Life Easier?

Expand All @@ -32,30 +34,30 @@ form. You can:
Support on Ko-Fi allows me to develop such tools as this one and perform
hardware-related experiments.

## How Does It Look Like?
## What Does It Look Like?

Title page
### Title Page

![Preview 1](https://user-images.githubusercontent.com/1590880/93708766-32ab0d80-fb39-11ea-8365-da2ca1b13d8b.jpg)

Property filter
### Property Filter

![Preview 2](https://user-images.githubusercontent.com/1590880/93708599-e01d2180-fb37-11ea-96b6-5d5eb4e0f285.jpg)

Component detail
### Component Detail

![Preview 3](https://user-images.githubusercontent.com/1590880/93708601-e0b5b800-fb37-11ea-84ed-6ba73f07911d.jpg)


## How Does It Work?

The page has no backend so it can be easily hosted on GitHub Pages. Therefore,
Travis CI download XLS spreadsheet from the JLC PCB page, a Python script
process it and it generates per-category JSON file with components.
The page has no backend so it can be easily hosted on GitHub Pages.
Travis CI downloads the XLSX spreadsheet from the JLCPCB page, a Python script
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we're updating the docs, it is worth it to change Travis to GH Action we use.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. That's why I made the change. This is the only instance of Travis.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I probably explained myself wrongly; the original wording is out-dated. We no longer use Travis CI, we use GH Actions. However, even after your update, you say we use Travis.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thank you. Fixed.

processes it, and it generates a per-category JSON file with components.

The frontend uses IndexedDB in the browser to store the component library and
perform queries on it. Therefore, before the first use, you have to download the
component library and it can take a while. Then, all the queries are performed
perform queries on it. Therefore, before the first use, the page downloads the
component library (it can take a while). Then, all the queries are performed
locally.

## Development
Expand All @@ -64,40 +66,43 @@ To get started with developing the frontend, you will need NodeJS & Python 3.

Set up the Python portion of the program by running:

```
```bash
$ virtualenv venv
$ source venv/bin/activate
$ pip install -e .
```

Then to download the cached parts list and process it, run:
Then to download the cached parts list (from the GH Pages site, generated via GH Actions) and process it, run:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, I find this extra information rather confusing - like I can see it is downloaded from the GH pages from the URL. And GH pages are in 99+% generated in GH actions.

Copy link
Author

@DeflateAwning DeflateAwning Nov 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GH Pages are not in 99% of GH Actions. GH Actions generally run unit tests. I know that you think it's obvious. I'm an experienced dev, and I did not think it's obvious, hence why I spent my weekend updating these docs. If you think that it's that obvious that I'm the only person who could get confused on this, feel free to request that I revert this change.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You misinterpreted my saying (and inverted the implication):

  • I say "something is provided via GH Pages" implies "it was probably built using CI, most probably GH Actions"
  • You read "We use GH Actions" implies "We have GH Pages"

What I dislike is "random pieces of information" scattered across the documentation. If you want to improve something, there should be "architecture overview" that captures the high-level design. It shouldn't pollute step-by-step instruction that the user is expected to just follow.

Copy link
Author

@DeflateAwning DeflateAwning Nov 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Propose a solution. Tell me what you want. We agree on the problem.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I said in another thread - a new document describing the overall architecture. But building such a document is currently out of my time scope.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's out of your timescope, can you just accept this change, and I'll split it out into a separate file later?


```
```bash
$ wget https://yaqwsx.github.io/jlcparts/data/cache.zip https://yaqwsx.github.io/jlcparts/data/cache.z0{1..8}
$ 7z x cache.zip
$ mkdir -p web/public/data/
$ jlcparts buildtables --jobs 0 --ignoreoldstock 30 cache.sqlite3 web/public/data
```

To understand how the GH Actions generate the cache zip file, refer to the
[update_components.yaml workflow](.github/workflows/update_components.yaml).

To launch the frontend web server, run:

```
```bash
$ cd web
$ npm install
$ npm start
```

## The Page Is Broken!
## Reporting Issues

Feel free to open an issue on GitHub.
If the page is broken, feel free to open an issue on GitHub.

## You Might Also Be Interested
## Related Projects

- [KiKit](https://github.com/yaqwsx/KiKit): a tool for automatic panelization of
KiCAD PCBs. It can also perform fully automatic export of manufacturing data
for JLC PCB assembly - read [the
for JLCPCB assembly - read [the
documentation](https://github.com/yaqwsx/KiKit/blob/master/doc/fabrication/jlcpcb.md)
or produce a solder-paste stencil for populating components missing at JLC PCB - read [the
or produce a solder-paste stencil for populating components missing at JLCPCB - read [the
documentation](https://github.com/yaqwsx/KiKit/blob/master/doc/stencil.md).
- [PcbDraw](https://github.com/yaqwsx/PcbDraw): a tool for making nice schematic
drawings of your boards and population manuals.
20 changes: 18 additions & 2 deletions jlcparts/datatables.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,22 @@ def normalizeAttribute(key, value):
assert isinstance(value, dict)
return key, value

def normalizeCapitalization(key):
"""
Given a category name, normalize capitalization. We turn everything
lowercase, but some known substring (such as MOQ or MHz) replace back to the
correct capitalization
"""
key = key.lower()
key = key[0].upper() + key[1:]

CAPITALIZATIONS = [
"MHz", "GHz", "Hz", "MOQ"
]
for capt in CAPITALIZATIONS:
key = key.replace(capt.lower(), capt)
return key

def normalizeAttributeKey(key):
"""
Takes a name of attribute and its value and returns a normalized key
Expand Down Expand Up @@ -170,7 +186,7 @@ def normalizeAttributeKey(key):
key = "Lifetime @ Temperature"
if key.startswith("Q @ Freq"):
key = "Q @ Frequency"
return key
return normalizeCapitalization(key)

def pullExtraAttributes(component):
"""
Expand Down Expand Up @@ -285,7 +301,7 @@ class MapCategoryParams:


def _map_category(val: MapCategoryParams):
# Sometimes, JLC PCB doesn't fill in the category names. Ignore such
# Sometimes, JLCPCB doesn't fill in the category names. Ignore such
# components.
if val.catName.strip() == "":
return None
Expand Down
4 changes: 2 additions & 2 deletions jlcparts/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def fetchLcscData(lcsc):
def getLibrary(source, db, age, limit):
"""
Download library inside OUTPUT (JSON format) based on SOURCE (csv table
provided by JLC PCB).
provided by JLCPCB).

You can specify previously downloaded library as a cache to save requests to
fetch LCSC extra data.
Expand Down Expand Up @@ -111,7 +111,7 @@ def fetchDetails(lcsc_code):
help="Be verbose")
def fetchTable(filename, verbose):
"""
Fetch JLC PCB component table
Fetch JLCPCB component table
"""
from .jlcpcb import pullComponentTable

Expand Down
7 changes: 3 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import setuptools


with open("README.md", "r") as fh:
long_description = fh.read()

Expand All @@ -11,10 +10,10 @@
version="0.1.0",
author="Jan Mrázek",
author_email="email@honzamrazek.cz",
description="Better view of JLC PCB parts",
description="Better view of JLCPCB parts",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/RoboticsBrno/JLCPCB-Parts",
url="https://github.com/yaqwsx/jlcparts",
packages=setuptools.find_packages(),
classifiers=[
"Programming Language :: Python :: 3",
Expand All @@ -36,4 +35,4 @@
"jlcparts=jlcparts.ui:cli"
],
}
)
)
4 changes: 2 additions & 2 deletions web/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta
name="JLC PCB SMD Assembly Component Catalogue"
content="Parametric search for components offered by JLC PCB SMD assembly service."
name="JLCPCB SMD Assembly Component Catalogue"
content="Parametric search for components offered by JLCPCB SMD assembly service."
/>

<link rel="apple-touch-icon" sizes="180x180" href="%PUBLIC_URL%/apple-touch-icon.png">
Expand Down
4 changes: 2 additions & 2 deletions web/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ function Header(props) {
<img src="./favicon.svg" alt="" className="block flex-none mr-4 h-auto"/>
<div className="flex-1">
<h1 className="text-4xl font-bold">
JLC PCB SMD Assembly Component Catalogue
JLCPCB SMD Assembly Component Catalogue
</h1>
<p>
Parametric search for components offered by <a href="https://jlcpcb.com" className="underline text-blue-600">JLC PCB</a> SMD assembly service.
Parametric search for components offered by <a href="https://jlcpcb.com" className="underline text-blue-600">JLCPCB</a> SMD assembly service.
</p>
<p>
Read more at project's <a className="underline text-blue-500 hover:text-blue-800" href="https://github.com/yaqwsx/jlcparts">GitHub page</a>.
Expand Down