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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: generate man pages #8525

Merged
merged 3 commits into from
Mar 14, 2024

Conversation

mohamedawnallah
Copy link
Contributor

@mohamedawnallah mohamedawnallah commented Mar 6, 2024

Change Description

Generate man pages automatically for both lncli and lnd commands and move the artifacts man pages lncli.1 and lnd.1 to /usr/local/share/man/man1 directory that process happens while running make install command.

Fixes #5605
Replaces #7424

Steps to Test

Steps for reviewers to follow to test the change.

Pull Request Checklist

Testing

  • Your PR passes all CI checks.
  • Tests covering the positive and negative (error paths) are included.
  • Bug fixes contain tests triggering the bug to prevent regressions.

Code Style and Documentation

馃摑 Please see our Contribution Guidelines for further guidance.

Copy link

coderabbitai bot commented Mar 6, 2024

Important

Auto Review Skipped

Auto reviews are limited to the following labels: llm-review. Please add one of these labels to enable auto reviews.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository.

To trigger a single review, invoke the @coderabbitai review command.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link
Collaborator

@ellemouton ellemouton left a comment

Choose a reason for hiding this comment

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

Nice! thanks for this.

Btw - maybe add to the PR description that this replaces #7424

cmd/lncli/commands.go Show resolved Hide resolved
cmd/lncli/commands.go Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
@@ -188,6 +188,9 @@
[Deprecate bumpclosefee for bumpforceclosefee and add `max_fee_rate` option
to `closechannel` cmd](https://github.com/lightningnetwork/lnd/pull/8350).

* Generate man pages automatically using `lncli generatemanpage` command for
both `lncli` and `lnd` commands when running `make install` in the Makefile (https://github.com/lightningnetwork/lnd/pull/8525).
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: see how the linking is done in other entries here. Make some part of the text clickable instead of just giving the raw link

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! Addressed

@mohamedawnallah mohamedawnallah force-pushed the generate-man-pages branch 2 times, most recently from e1da675 to 45c7cc3 Compare March 9, 2024 21:56
Copy link
Collaborator

@ellemouton ellemouton left a comment

Choose a reason for hiding this comment

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

see my comment re swallowing the error warning with some bash trickery

@mohamedawnallah
Copy link
Contributor Author

Thanks again @ellemouton for your review. I've addressed all your comments!

Copy link
Collaborator

@ellemouton ellemouton left a comment

Choose a reason for hiding this comment

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

Thanks @mohamedawnallah ,

I think we should instead put the script in a dedicated bash script & then call it from the makefile. That way we can reduce the logs printed out too.

So I suggest converting the makefile method to:

manpages:
	@$(call print, "Generating man pages lncli.1 and lnd.1.")
	./scripts/gen_man_pages.sh $(DESTDIR) $(PREFIX)

and then add a gen_man_pages.sh file to the scripts folder with the following contents:

#!/bin/bash

# Usage: ./gen_man_pages.sh DESTDIR PREFIX

DESTDIR="$1"
PREFIX="$2"

# Check if lncli is installed.
if ! command -v lncli &> /dev/null
then
    echo "lncli could not be found. Please install lncli before running this script."
    exit 1
fi

# Ignore warnings regarding HTMLBlock detection in go-md2man package
# since using "<...>" is part of our docs.
lncli generatemanpage 2>&1 | grep -v "go-md2man does not handle node type HTMLSpan" || true

echo "Installing man pages to $DESTDIR$PREFIX/share/man/man1."
install -m 644 lnd.1 "$DESTDIR$PREFIX/share/man/man1/lnd.1"
install -m 644 lncli.1 "$DESTDIR$PREFIX/share/man/man1/lncli.1"

let me know what you think :)

Comment on lines 197 to 198
* [Generate man pages automatically using `lncli generatemanpage` command
for both `lncli` and `lnd` commands](https://github.com/lightningnetwork/lnd/pull/8525) when running `make install` in the Makefile.
Copy link
Collaborator

Choose a reason for hiding this comment

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

pls try wrap this to 80 chars 馃檹

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! Addressed

Copy link
Collaborator

@ellemouton ellemouton left a comment

Choose a reason for hiding this comment

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

ah - one other thing.

Currently, if you run make manpages, it builds the lnd.1 and lncli. pages in the current directory & then I think install copies them over to the man directory. We should delete them from the current directory.

@mohamedawnallah mohamedawnallah force-pushed the generate-man-pages branch 2 times, most recently from e14be78 to 18bfb77 Compare March 11, 2024 12:17
@mohamedawnallah
Copy link
Contributor Author

Thanks @ellemouton for your feedback. I agree with isolating the man pages script into an isolated bash script it is a much better solution. I've addressed all of your feedback!

Copy link
Collaborator

@ellemouton ellemouton left a comment

Choose a reason for hiding this comment

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

@mohamedawnallah - did you test this?

make manpages
 Generating man pages lncli.1 and lnd.1.
./scripts/gen_man_pages.sh  /usr/local
make: ./scripts/gen_man_pages.sh: Permission denied
make: *** [manpages] Error 1

you need to make sure that the new bash script file is executable.

In general, pls always make sure to tests your changes & also to wait for the CI to be green (besides some flakes) before re-requesting review 馃檹 馃槉

@mohamedawnallah
Copy link
Contributor Author

I'm running on zsh on mac I though that was the problem 馃榿. But you're alright I should have tested it locally before pushing it 馃憤

@mohamedawnallah
Copy link
Contributor Author

In general, pls always make sure to tests your changes & also to wait for the CI to be green (besides some flakes) before re-requesting review 馃檹 馃槉

Acknowledged 馃憤

Copy link
Collaborator

@ellemouton ellemouton left a comment

Choose a reason for hiding this comment

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

LGTM! Great work @mohamedawnallah 馃檹

One last micro nit :) otherwise - LGTM

Makefile Outdated Show resolved Hide resolved
Copy link
Collaborator

@guggero guggero left a comment

Choose a reason for hiding this comment

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

Very nice. Looks good to me, one comment about the Makefile.

Makefile Show resolved Hide resolved
Copy link
Collaborator

@guggero guggero left a comment

Choose a reason for hiding this comment

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

Final nit, otherwise LGTM 馃帀

#? install: Build and install lnd and lncli binaries, place them in $GOPATH/bin
install:
#? install: Build and install lnd and lncli binaries, place them in $GOPATH/bin.
install-binaries:
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: the help hint for this make goal is now outdated. Also, looking at all other help hints, we don't use full stops at the end of sentences everywhere else, so let's make this and the ones below consistent with the rest of the file.

@guggero guggero merged commit 73058c7 into lightningnetwork:master Mar 14, 2024
26 of 27 checks passed
@mohamedawnallah mohamedawnallah deleted the generate-man-pages branch March 31, 2024 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: generate man pages
4 participants