-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
OO refactoring and git-blame preloading #12
Conversation
Create a Git repository abstraction with just what we need. This will be continued with a Book class holding/storing the info about the whole book, its size and its authors.
Have dedicated objects: - Repo - Author - Page - Commit handle all the data and responsibilities.
This commit creates the Page objects within the on_files MkDocs event. As a result the lines/contribution statistics for the whole book are now available from within *every* Markdown page.
# Conflicts: # mkdocs_git_authors_plugin/plugin.py # mkdocs_git_authors_plugin/util.py
The 00000 "commit" shown by git blame for uncommitted lines caused the plugin to crash when trying to execute "git show" on it. Therefore uncommitted stuff is attributed to a fake author whose display characteristics are configurable.
Inserting {{ git_authors_list }} in any Markdown file will insert a list of all authors along with their contribution to the whole site. Adds configuration options: - show_lines (default: false) also show the line count in the list (but not on a page's summary) - label_lines (for localization) TODO: Provide *real* configurability of the resulting HTML
I've now added th ### Mitwirkende
Folgende Autoren haben an der Erstellung dieser Dokumentation mitgewirkt:
{{ git_authors_list }} results in the following output: with the following configuration: - git-authors:
show_contribution: true
show_lines: true
label_lines: Zeilen
uncommitted_name: Nicht gesichert The "Nicht gesichert" refers to just this example which hasn't been committed. I think I would like to see an option [This of course still breaks all unit tests.] |
Adds configuration options - sort_by (choice: 'name', 'contribution') - sort_reverse (bool, default: False)
With the sort order I think I'm basically done with everything I'd like to have added to the plugin. If you basically agree with the restructuring in this PR
I have a final suggestion for you, if you agree with my approach to removing GitPython support: I would merge this (as a PyPi package) with the |
There may be users not interested in counting empty lines as content.
Sorry, yet another one ;-) |
Wow, I can see you definitely went for it ! Starting to enjoy the open source work @uliska ? This is a huge PR, which also means I have a lot of comments. I focussed especially on maintainability and simplicity. In general I think it's a great PR that will really help with future additions as well. I realise it addresses your specific needs, but it still needs more work to get to a place where it is very usably for a large group of people. I already mentioned them in the specific review comments, but main review points are:
Thanks for the suggestion. I'd prefer to keep depending on Before working on adding docs and unit tests, let's address the review comments first OK ? |
Well, if you look at my profile you may realize that "starting" doesn't really pin it down ;-) (and that's only GitHub). Rather I tend to become creative extending code with (generally) useful stuff - when there's something to build upon.
I'm aware of that. But things will only move on when started in the first place.
I seem to be missing something, but I don't see any review comments.
I assume I'll see what you mean once I see the review comments?
I suggest leaving that question to itself for a few days to see what comes out of contemplating it.
I don't think converting my code into a standalone Git wrapper makes a lot of sense. The point of the exercise basically was to only implement what's actually needed for the "client" (the plugin). Once it is exposed to a "general audience" all kinds of requests would come, and it would end as a less-tested GitPython.
I will not push you on this, but maybe there's a misunderstanding here. I didn't talk about copying the code. I was thinking of one common Python package that includes two MkDocs plugins as exposed through different entry points in the For today my time is completely taken up, but I'll consider your comments in more detail when I get the chance to see your individual review comments (maybe there's an option to finally publish a review?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see now that I need to 'submit' the review!
Looking at your profile it seems you are much more experienced in OS than me for sure ;) What I meant was that it looks like you are starting to enjoy the work on this plugin. For me at least I find it very cool to make tools that others use! Hopefully I'll learn a bit from you as we go through the review comments.
And yes, I did misunderstand your point on merging with mkdocs-revision-date-plugin
. Actually it makes sense, as there are many common components. I need to think about this, and I might open a new issue to discuss / document.
We don't have to go through the member accessor function when we have the repo reference as a function argument.
This method is only used once and can easily be avoided by directly passing the sha argument to Commit._populate. Incidentally: Move the handling of uncommitted lines *into* Commit._populate
This is not related to the actual object but a simple conversion function and therefore an optimal candidate for a generic "util" module
The previous name raised concerns about users being worried "commit" might be used as a verb (i.e. creating commits in the actual repository).
The configuration variables intended for localization have to be removed because the functionality will at one point be handled by localization. See timvink#14
I've gone through the review comments. Indeed Pull Requests should not be so heavy, but as said at one point I didn't see any chance for an in-between anymore. I've marked many comments as "resolved", in most cases after addressing them with a commit. A number of comments are not immediately resolvable and I added comments and questions. One general remark: I've stated disagreement in quite a number of cases. Please don't get me wrong with these - I don't want to appear arrogant, and I don't want to fight over these issues. But it's important to clearly express differing opinions in order to be able to resolve them for the best. So I won't be offended if you disagree with my comments on your turn ... There are two recurring issues where we either have different ideas about programming style or where you may not fully see my idea (which does not mean my idea is correct or the best solution). A)
I think the paradigm of encapsulation says it is always better to have a method B) |
I agree, and thanks for all your comments. I really appreciate the conversation ! Indeed some discussions about different programming styles, but educational for me as well. I resolved most discussions, couple of points where we need to think a bit more. Getting there! |
This is necessary to get a hold on the whole element through CSS, for example to make it invisible (in certain contexts).
It should be clear to any future contributor that when the on_page event stage is reached all pages have already been parsed and the repo-wide statistics are available.
This is to separate concerns: Move the formatting of the list of authors to the repo not in the Git classes but separately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, and thanks for all your comments. I really appreciate the conversation !
Indeed some discussions about different programming styles, but educational for me as well.
I have the impression that we both are completely ready to accept the other's arguments, which is a good basis for collaboration.
I will have to leave now and hopefully find more time tonight on the git-blame
issue.
Closes timvink#20 While parsing the --porcelain output of git blame is more complicated than that of git blame -lts * it should be considered more robust * it provides substantially more information: - we can get all information about the commits that we need - this makes it obsolete to call `git show` on the commits The format of the commit timestamp is different in this command, therfore this had to modify the datetime processing functions, which were moved to util.py at the same time.
Merged! 🎉 Amazing work @uliska ! |
This has become more involved and intrusive than I'd prefer at this point of contribution to a repository, and I'm feeling somewhat uneasy about it. However, it became an all-or-nothing thing and wouldn't have made sense to send slice by slice.
This PR does more than one thing unforfunately:
on_files
eventI think this restructuring will make it easier to add more functionality and is therefore useful.
It does not include a proposal for #9 yet although that should be trivial.
This commit completely breaks the unit tests, but I didn't want to put my hands on these before getting some feedback on the PR itself.