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

Added Cell level control for Table Borders #1285

Merged
merged 1 commit into from
Nov 12, 2024
Merged

Conversation

Kaustbh
Copy link

@Kaustbh Kaustbh commented Oct 15, 2024

Fixes : #1192

Implemented a new feature that allows granular, cell-level control over table borders. With this update, users can now define specific borders (left, right, top, bottom) for individual cells, offering greater customization when generating tables in PDFs.

Checklist:

  • The GitHub pipeline is OK (green),
    meaning that both pylint (static code analyzer) and black (code formatter) are happy with the changes of this PR.

  • A unit test is covering the code added / modified by this PR

  • This PR is ready to be merged

  • In case of a new feature, docstrings have been added, with also some documentation in the docs/ folder

  • A mention of the change is present in CHANGELOG.md

By submitting this pull request, I confirm that my contribution is made under the terms of the GNU LGPL 3.0 license.

@Kaustbh
Copy link
Author

Kaustbh commented Oct 15, 2024

Hi @Lucas-C, I have made a PR to know if I am doing it correctly it is not a complete implementation, please see the code change and give me suggestions.

fpdf/table.py Outdated Show resolved Hide resolved
fpdf/table.py Outdated Show resolved Hide resolved
fpdf/table.py Outdated Show resolved Hide resolved
fpdf/table.py Outdated Show resolved Hide resolved
@Lucas-C
Copy link
Member

Lucas-C commented Oct 16, 2024

Hi @Lucas-C, I have made a PR to know if I am doing it correctly it is not a complete implementation, please see the code change and give me suggestions.

Nice, thank you for creating a PR 🙂

I made a few comments.

One thing that should come next is to add unit tests! 🙂

@Kaustbh
Copy link
Author

Kaustbh commented Oct 19, 2024

Hi, I made the suggested changes, now how can I fix this pylint warning,
fpdf/table.py:255:4: R0911: Too many return statements (7/6) (too-many-return-statements)
which is caused because of additional return str(border).

And please tell me where I should add the unit tests.

@Lucas-C
Copy link
Member

Lucas-C commented Oct 21, 2024

Hi, I made the suggested changes, now how can I fix this pylint warning, fpdf/table.py:255:4: R0911: Too many return statements (7/6) (too-many-return-statements) which is caused because of additional return str(border).

It now seems to be passing, but you have however 27 failing tests.

And please tell me where I should add the unit tests.

You can add them to test/table/test_table.py.

@Kaustbh
Copy link
Author

Kaustbh commented Oct 24, 2024

Hi @Lucas-C, should I write test just like this? and for all the different values like, right, top, etc.

def test_cell_border_left(tmp_path):
    pdf = FPDF()
    pdf.add_page()
    pdf.set_font("Times", size=5)
    with pdf.table( gutter_height=2, gutter_width=2) as table:

        for data_row in TABLE_DATA:
            row = table.row()
            for datum in data_row:
                row.cell(datum,border="left")
    assert_pdf_equal(pdf, HERE / "test_cell_border_left.pdf", tmp_path)

@Kaustbh
Copy link
Author

Kaustbh commented Oct 26, 2024

@Lucas-C is it the right way of writing the tests?

@Lucas-C
Copy link
Member

Lucas-C commented Oct 26, 2024

Hi @Lucas-C, should I write test just like this? and for all the different values like, right, top, etc.

Yes, this look likes a good start 👍
As mentioned on https://py-pdf.github.io/fpdf2/Development.html, you can pass generate=True once to assert_pdf_equal() in order to generate a reference PDF file.

And testing many possible combination of values is also a good idea!

@Kaustbh
Copy link
Author

Kaustbh commented Oct 27, 2024

is it fine @Lucas-C ?

@Kaustbh Kaustbh requested a review from Lucas-C October 28, 2024 17:01
test/text/test_cell.py Outdated Show resolved Hide resolved
Copy link
Member

@Lucas-C Lucas-C left a comment

Choose a reason for hiding this comment

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

is it fine @Lucas-C ?

There are a couple of minor things remaining to be fixed, and also could you please add a mention of this addition in the CHANGELOG.md file?

The I'll be happy to merge your PR 👍 🙂

@Kaustbh
Copy link
Author

Kaustbh commented Nov 1, 2024

Hi @Lucas-C,

Should I add documentation for this as well, or would it be better to address it in a new issue? Creating a separate issue might also be a good idea, as it would give me the opportunity to make an additional contribution 🙂

@Lucas-C
Copy link
Member

Lucas-C commented Nov 1, 2024

Should I add documentation for this as well, or would it be better to address it in a new issue? Creating a separate issue might also be a good idea, as it would give me the opportunity to make an additional contribution 🙂

We usually integrate the documentation related to new features as part of the PR that introduced it, so yes, it would be a good idea to include some documentation as part of this PR 🙂

Also, have you seen my other previous comments regarding the remaing minor changes required?

@Kaustbh
Copy link
Author

Kaustbh commented Nov 1, 2024

Yes, I have made the changes you suggested.

@Lucas-C
Copy link
Member

Lucas-C commented Nov 1, 2024

Yes, I have made the changes you suggested.

I'm sorry but I don't think you adressed those 4 distinct points:

also could you please add a mention of this addition in the CHANGELOG.md file?

We usually integrate the documentation related to new features as part of the PR that introduced it, so yes, it would be a good idea to include some documentation as part of this PR 🙂

@Kaustbh
Copy link
Author

Kaustbh commented Nov 1, 2024

I haven't committed it yet.

@Lucas-C
Copy link
Member

Lucas-C commented Nov 1, 2024

I haven't committed it yet.

Oh OK, alright, that's fine🙂
Take your time 👍

@Kaustbh
Copy link
Author

Kaustbh commented Nov 6, 2024

Hi @Lucas-C, I have made the changes and also added documentation. I'm sorry, but I was not able to render the API documentation on my laptop. Please review the code and let me know if any changes are required.

CHANGELOG.md Outdated Show resolved Hide resolved
docs/Tables.md Outdated Show resolved Hide resolved
docs/Tables.md Outdated Show resolved Hide resolved
docs/Tables.md Show resolved Hide resolved
docs/Tables.md Show resolved Hide resolved
docs/Tables.md Show resolved Hide resolved
docs/Tables.md Outdated Show resolved Hide resolved
Copy link
Member

@Lucas-C Lucas-C left a comment

Choose a reason for hiding this comment

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

Good job overall 👍 👍 👍

You wrote really good code, good documentation and good tests!

There are only a few minor details remaining:

@Kaustbh
Copy link
Author

Kaustbh commented Nov 11, 2024

@Lucas-C please review the commit.

@Lucas-C
Copy link
Member

Lucas-C commented Nov 12, 2024

@allcontributors pleasae add @Kaustbh for code

Copy link

@Lucas-C

I've put up a pull request to add @Kaustbh! 🎉

@Lucas-C Lucas-C merged commit 304d5ca into py-pdf:master Nov 12, 2024
11 checks passed
@Lucas-C
Copy link
Member

Lucas-C commented Nov 12, 2024

Merged!

Thanks a lot for your contribution @Kaustbh 👍

You have been added to the list of fpdf2 contributors: https://github.com/py-pdf/fpdf2?tab=readme-ov-file#contributors-

@Kaustbh
Copy link
Author

Kaustbh commented Nov 12, 2024

It was a pleasure contributing and I'm honored to be included in the list of contributors. I am looking forward to collaborating more in the future and contributing to more features and improvements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Cell Level Controll for Table Borders
2 participants