lyx_mirror/src/insets/InsetBibtex.h

113 lines
2.4 KiB
C
Raw Normal View History

// -*- C++ -*-
/**
* \file InsetBibtex.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Alejandro Aguilar Sierra
*
* Full author contact details are available in file CREDITS.
*/
#ifndef INSET_BIBTEX_H
#define INSET_BIBTEX_H
#include "InsetCommand.h"
namespace lyx {
class BiblioInfo;
namespace support {
class FileName;
class FileNamePairList;
Bulk cleanup/fix incorrect annotation at the end of namespaces. This commit does a bulk fix of incorrect annotations (comments) at the end of namespaces. The commit was generated by initially running clang-format, and then from the diff of the result extracting the hunks corresponding to fixes of namespace comments. The changes being applied and all the results have been manually reviewed. The source code successfully builds on macOS. Further details on the steps below, in case they're of interest to someone else in the future. 1. Checkout a fresh and up to date version of src/ git pull && git checkout -- src && git status src 2. Ensure there's a suitable .clang-format in place, i.e. with options to fix the comment at the end of namespaces, including: FixNamespaceComments: true SpacesBeforeTrailingComments: 1 and that clang-format is >= 5.0.0, by doing e.g.: clang-format -dump-config | grep Comments: clang-format --version 3. Apply clang-format to the source: clang-format -i $(find src -name "*.cpp" -or -name "*.h") 4. Create and filter out hunks related to fixing the namespace git diff -U0 src > tmp.patch grepdiff '^} // namespace' --output-matching=hunk tmp.patch > fix_namespace.patch 5. Filter out hunks corresponding to simple fixes into to a separate patch: pcregrep -M -e '^diff[^\n]+\nindex[^\n]+\n--- [^\n]+\n\+\+\+ [^\n]+\n' \ -e '^@@ -[0-9]+ \+[0-9]+ @@[^\n]*\n-\}[^\n]*\n\+\}[^\n]*\n' \ fix_namespace.patch > fix_namespace_simple.patch 6. Manually review the simple patch and then apply it, after first restoring the source. git checkout -- src patch -p1 < fix_namespace_simple.path 7. Manually review the (simple) changes and then stage the changes git diff src git add src 8. Again apply clang-format and filter out hunks related to any remaining fixes to the namespace, this time filter with more context. There will be fewer hunks as all the simple cases have already been handled: clang-format -i $(find src -name "*.cpp" -or -name "*.h") git diff src > tmp.patch grepdiff '^} // namespace' --output-matching=hunk tmp.patch > fix_namespace2.patch 9. Manually review/edit the resulting patch file to remove hunks for files which need to be dealt with manually, noting the file names and line numbers. Then restore files to as before applying clang-format and apply the patch: git checkout src patch -p1 < fix_namespace2.patch 10. Manually fix the files noted in the previous step. Stage files, review changes and commit.
2017-07-23 11:11:54 +00:00
} // namespace support
/** Used to insert BibTeX's information
*/
class InsetBibtex : public InsetCommand {
public:
///
InsetBibtex(Buffer *, InsetCommandParams const &);
///
~InsetBibtex();
///
support::FileNamePairList getBibFiles() const;
///
bool addDatabase(docstring const &);
///
bool delDatabase(docstring const &);
///
void write(std::ostream &) const;
/// \name Public functions inherited from Inset class
//@{
///
docstring toolTip(BufferView const & bv, int x, int y) const;
///
bool hasSettings() const { return true; }
///
InsetCode lyxCode() const { return BIBTEX_CODE; }
///
DisplayType display() const { return AlignCenter; }
///
void latex(otexstream &, OutputParams const &) const;
///
int plaintext(odocstringstream & ods, OutputParams const & op,
size_t max_length = INT_MAX) const;
///
void collectBibKeys(InsetIterator const &) const;
///
void validate(LaTeXFeatures &) const;
///
docstring xhtml(XHTMLStream &, OutputParams const &) const;
///
std::string contextMenuName() const;
//@}
/// \name Static public methods obligated for InsetCommand derived classes
//@{
///
static ParamInfo const & findInfo(std::string const &);
///
static std::string defaultCommand() { return "bibtex"; }
///
static bool isCompatibleCommand(std::string const & s)
{ return s == "bibtex"; }
//@}
private:
/// look up the path to the file using TeX
static support::FileName
getBibTeXPath(docstring const & filename, Buffer const & buf);
///
void editDatabases() const;
///
void parseBibTeXFiles() const;
2017-01-08 08:39:46 +00:00
///
bool usingBiblatex() const;
/// \name Private functions inherited from Inset class
//@{
///
bool getStatus(Cursor & cur, FuncRequest const & cmd,
FuncStatus & flag) const;
///
void doDispatch(Cursor & cur, FuncRequest & cmd);
///
Inset * clone() const { return new InsetBibtex(*this); }
//@}
/// \name Private functions inherited from InsetCommand class
//@{
///
docstring screenLabel() const;
//@}
};
} // namespace lyx
#endif // INSET_BIBTEX_H